xsl-list
[Top] [All Lists]

Re: [xsl] What is the appropriate XPath 2.0 expression to reference an XSD simpleType ?

2015-12-29 08:21:14
Are you looking for something like

*[local-name()=‘base’ and (namespace-uri()=‘’ or 
namespace-uri()=‘http://www.w3.org/2001/XMLSchema']

Dan 




On 12/29/15, 9:09 AM, "Costello, Roger L. costello(_at_)mitre(_dot_)org" 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:

Hi Folks,

My XSLT program needs to add a new simpleType to this schema:

<schema xmlns="http://www.w3.org/2001/XMLSchema";
              targetNamespace="T"
              xmlns:t="T">
   
   <simpleType name="base">
       <restriction base="string" />
   </simpleType>

</schema>

My XSLT needs to add this:

   <simpleType name="titleType">
       <restriction base="t:base">
           <maxLength value="20" />
       </restriction>
   </simpleType>

Of course, if the schema is designed like this:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
                  targetNamespace="T"
                  xmlns="T">
   
   <xs:simpleType name="base">
       <xs:restriction base="xs:string" />
   </xs:simpleType>

</xs:schema>

Then my XSLT needs to add this:

   <xs:simpleType name="titleType">
       <xs:restriction base="base">
           <xs:maxLength value="20" />
       </xs:restriction>
   </xs:simpleType>

And if the schema does not have a targetNamespace:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";>
   
   <xs:simpleType name="base">
       <xs:restriction base="xs:string" />
   </xs:simpleType>

</xs:schema>

Then my XSLT needs to add this:

   <xs:simpleType name="titleType">
       <xs:restriction base="base">
           <xs:maxLength value="20" />
       </xs:restriction>
   </xs:simpleType>

I am struggling with the appropriate XPath 2.0 expression to reference the 
base simpleType. In the first schema, referencing the base simpleType must be 
expressed this way:

      t:base

In the second and third schemas, referencing the base simpleType must be 
expressed this way:

      base

My XSLT has a template rule containing this:

   <xs:simpleType name="titleType">
       <xs:restriction base="_____">
           <xs:maxLength value="20" />
       </xs:restriction>
   </xs:simpleType>

What is the appropriate XPath 2.0 expression to use in _____?

/Roger
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1340029
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>