Subject: RE: [xsl] How to get a list of XPath out of XMl schema documents - clarification From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Fri, 25 Feb 2005 10:44:18 -0000 |
Nice to see you quoting David Wheeler - the inventor of the subroutine, it is said. He was a great computer scientist, with a wry sense of humour, but an appallingly bad lecturer. I think I was one of only two students who stuck it to the end of his course on numerical algorithms, and that was more out of sympathy than because I was learning anything. It seems that you do indeed want to work from the schema rather than from an instance document. There are several difficulties in doing this. Firstly, any global element declaration in the schema is a potential top-level element in an instance document. You could get around this by supplying the root element name as an input to your generator, which would then only produce paths starting at this element. Secondly, wildcards. Simplest solution would be, if you find an element wildcard (xs:any), just output the path with a trailing "//*". Thirdly, namespaces. If you only want a solution for your own schemas and your own schemas don't use namespaces, then you can ignore this problem and the it becomes about 90% easier. But of course a general purpose solution has to tackle this. Fourthly, include/import/redefine. Again, you can wish this problem away if it doesn't affect you. Your particular schema doesn't even include named model groups or named complex types, which makes it very simple. However, sooner or later you're going to find your schema using these extra levels of indirection, and as your quote from David Wheeler rightly points out, this is going to create extra problems. So the question really is, how general purpose do you want your solution to be? If you restrict it to simple examples like the one quoted, it's very easy, but to handle schemas in general, it's tough. Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: "Michael Lindenau (geschdftlich)" > [mailto:michael.lindenau@xxxxxxxxxxxxxxxxxxxxxx] > Sent: 25 February 2005 10:21 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] How to get a list of XPath out of XMl schema > documents - clarification > > First - thanks to everybody for the fast answers and for the hints so > far (even that I didn't get Dimitres example to run - using Stylus > Studio with MSXML/MSXML 4.0). This seems to me a great and helpful > mailing list. > > Second - The XPaths of the XML schema documents are used to create > mappings between EDI field descriptions and the XML file in > which they > should be transferred. The XML schemas are the base for the mapping > design. First intention is, to control if every given XPath in the > mapping documents (usually Excel sheets) is correct written. Next > intention is, to get an easy diff about the ongoing changes > in the XML > schema documents. So hierarchy doesn't matter. It's only > important that > the list contains every used unique XPath to an named element. > Namespaces are not used. Indeed the XML schemata are very simple and > don't use much of the possibilities that an XML schema offers. But at > least they group elements to complex elements and use > references. There > is no elaborated software intended, which will use this information. > > Below is a concrete example of such a schema > > The desired XSLT would produce a list like > > /OBBISOFT/MESSAGE/MESSAGE_NO > /OBBISOFT/MESSAGE/MESSAGE_VERSION_NO > /OBBISOFT/MESSAGE/MESSAGE_SENDER/MAIN > /OBBISOFT/MESSAGE/MESSAGE_SENDER/CENTER > /OBBISOFT/MESSAGE/MESSAGE_SENDER/TEAM > ... > > which lists only the elements. > > A list like > /OBBISOFT > /OBBISOFT/MESSAGE > /OBBISOFT/MESSAGE/MESSAGE_NO > wouldn't be the desired output. > > <?xml version="1.0" encoding="UTF-8"?> > <!--***************************************************--> > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" > elementFormDefault="qualified"> > <!--***************************************************--> > <!--** SIMPLE TYPES--> > <!--***************************************************--> > <xs:simpleType name="NotEmptyString"> > <xs:restriction base="xs:string"> > <xs:minLength value="1"/> > </xs:restriction> > </xs:simpleType> > <xs:simpleType name="DurationType"> > <xs:restriction base="xs:string"> > <xs:minLength value="1"/> > </xs:restriction> > </xs:simpleType> > <xs:simpleType name="BooleanType"> > <xs:restriction base="xs:string"> > <xs:enumeration value="TRUE"/> > <xs:enumeration value="FALSE"/> > </xs:restriction> > </xs:simpleType> > <!--***************************************************--> > <!--** ELEMENTS--> > <!--***************************************************--> > <!--ROLEType--> > <!--NotEmptyString--> > <xs:element name="CENTER" type="NotEmptyString"/> > <xs:element name="CTO_NO" type="NotEmptyString"/> > <xs:element name="ERROR_ID" type="NotEmptyString"> > <xs:annotation> > <xs:documentation>Type of error</xs:documentation> > </xs:annotation> > </xs:element> > <xs:element name="ERROR_KIND" type="NotEmptyString"> > <xs:annotation> > <xs:documentation>Describes the nature of the error > > See list of domain values</xs:documentation> > </xs:annotation> > </xs:element> > <xs:element name="ERROR_MEANING" type="NotEmptyString"/> > <xs:element name="EXT_SYSTEM" type="NotEmptyString"> > <xs:annotation> > <xs:documentation>For external message consignee or > dedicated system name</xs:documentation> > </xs:annotation> > </xs:element> > <xs:element name="MAIN" type="NotEmptyString"/> > <xs:element name="MESSAGE_NO" type="NotEmptyString"> > <xs:annotation> > <xs:documentation>Running counter of the message > for unique > identification</xs:documentation> > </xs:annotation> > </xs:element> > <xs:element name="REFERENCE" type="NotEmptyString"/> > <xs:element name="TEAM" type="NotEmptyString"/> > <xs:element name="TOURNEE" type="NotEmptyString"/> > <!--***************************************************--> > <!--long--> > <!--***************************************************--> > <!--int--> > <xs:element name="MESSAGE_VERSION_NO"> > <xs:annotation> > <xs:documentation>Design version of the > message</xs:documentation> > </xs:annotation> > <xs:simpleType> > <xs:restriction base="xs:integer"> > <xs:minInclusive value="0"/> > <xs:maxInclusive value="999"/> > </xs:restriction> > </xs:simpleType> > </xs:element> > <!--***************************************************--> > <!--decimal--> > <!--***************************************************--> > <!--date--> > <!--***************************************************--> > <!--duration--> > <!--***************************************************--> > <!--boolean--> > <xs:element name="TRUCK_NO" type="NotEmptyString"/> > <xs:element name="OBBISOFT"> > <xs:complexType> > <xs:sequence> > <xs:element name="MESSAGE"> > <xs:complexType> > <xs:sequence> > <xs:element ref="MESSAGE_NO"/> > <xs:element ref="MESSAGE_VERSION_NO"/> > <xs:element name="MSG_SENDER"> > <xs:annotation> > <xs:documentation>Organisational > unit sending the message</xs:documentation> > </xs:annotation> > <xs:complexType> > <xs:choice> > <xs:annotation> > <xs:documentation>1 or > Both</xs:documentation> > </xs:annotation> > <xs:choice> > <xs:element > name="ORGANIZATION"> > <xs:annotation> > > <xs:documentation>For DHL internal message > consignee</xs:documentation> > </xs:annotation> > <xs:complexType> > <xs:sequence> > <xs:element > ref="MAIN"/> > <xs:element > ref="CENTER"/> > <xs:element > ref="TEAM"/> > </xs:sequence> > </xs:complexType> > </xs:element> > <xs:element > ref="EXT_SYSTEM"/> > </xs:choice> > <xs:sequence> > <xs:annotation> > <xs:documentation/> > </xs:annotation> > <xs:element > name="ORGANIZATION"> > <xs:annotation> > > <xs:documentation>For DHL internal message > consignee</xs:documentation> > </xs:annotation> > <xs:complexType> > <xs:sequence> > <xs:element > ref="MAIN"/> > <xs:element > ref="CENTER"/> > <xs:element > ref="TEAM"/> > </xs:sequence> > </xs:complexType> > </xs:element> > <xs:element > ref="EXT_SYSTEM"/> > </xs:sequence> > </xs:choice> > </xs:complexType> > </xs:element> > <xs:element name="MSG_CONSIGNEE"> > <xs:annotation> > <xs:documentation>Organisational > unit receiving the message</xs:documentation> > </xs:annotation> > <xs:complexType> > <xs:choice> > <xs:annotation> > <xs:documentation>1 or > Both</xs:documentation> > </xs:annotation> > <xs:choice> > <xs:element > name="ORGANIZATION"> > <xs:annotation> > > <xs:documentation>For DHL internal message > consignee</xs:documentation> > </xs:annotation> > <xs:complexType> > <xs:sequence> > <xs:element > ref="MAIN"/> > <xs:element > ref="CENTER"/> > <xs:element > ref="TEAM"/> > </xs:sequence> > </xs:complexType> > </xs:element> > <xs:element > ref="EXT_SYSTEM"/> > </xs:choice> > <xs:sequence> > <xs:element > name="ORGANIZATION"> > <xs:annotation> > > <xs:documentation>For DHL internal message > consignee</xs:documentation> > </xs:annotation> > <xs:complexType> > <xs:sequence> > <xs:element > ref="MAIN"/> > <xs:element > ref="CENTER"/> > <xs:element > ref="TEAM"/> > </xs:sequence> > </xs:complexType> > </xs:element> > <xs:element > ref="EXT_SYSTEM"/> > </xs:sequence> > </xs:choice> > </xs:complexType> > </xs:element> > <xs:element name="MSG_ERROR" > minOccurs="0" > maxOccurs="unbounded"> > <xs:annotation> > > <xs:documentation>Contains the error > messages generated by the MessageManager module during > integration/extraction</xs:documentation> > </xs:annotation> > <xs:complexType> > <xs:sequence> > <xs:element ref="ERROR_ID"/> > <xs:element > ref="ERROR_MEANING"/> > <xs:element ref="REFERENCE" > minOccurs="0"/> > </xs:sequence> > </xs:complexType> > </xs:element> > <xs:choice> > <xs:element name="STANDARD_MESSAGE"> > <xs:annotation> > <xs:documentation>NPS > messages</xs:documentation> > </xs:annotation> > <xs:complexType> > <xs:choice> > <xs:choice> > <xs:annotation> > > <xs:documentation>NPS Messages</xs:documentation> > </xs:annotation> > <xs:element > name="DC_INPUT"> > <xs:annotation> > > <xs:documentation>Input from the Swedish Tour Optimisation Software > > Please note: The MAIN is specified in ../MSG_CONSIGNEE/MAIN > </xs:documentation> > </xs:annotation> > <xs:complexType> > <xs:sequence> > > <xs:element > name="DC_INPUTS" maxOccurs="unbounded"> > > <xs:complexType> > > <xs:sequence> > > > <xs:annotation> > > > <xs:documentation>CTO_NO > Contains the DHL identification number of the (delivery-) > operation that > has been optimised. > > SUBBAY_ID is a dedicated area inside a terminal where the > goods for the > above operation will be stored > > TOURNEE contains the standard round trip to be used to > execute the operation > > TRUCK_NO = > registration plate number of the truck performing the round trip > </xs:documentation> > > > </xs:annotation> > > > <xs:element ref="CTO_NO"/> > > > <xs:element name="SUBBAY_ID" type="NotEmptyString"/> > > > <xs:element ref="TOURNEE" minOccurs="0"/> > > > <xs:element ref="TRUCK_NO" minOccurs="0"/> > > </xs:sequence> > > </xs:complexType> > > </xs:element> > </xs:sequence> > </xs:complexType> > </xs:element> > </xs:choice> > </xs:choice> > </xs:complexType> > </xs:element> > </xs:choice> > </xs:sequence> > </xs:complexType> > </xs:element> > </xs:sequence> > </xs:complexType> > </xs:element> > </xs:schema> > > > -- > > Kind regards > > Michael Lindenau > Lvsungen+Ideen > > "Any problem in computer science can be solved with > another layer of indirection. But that usually will > create another problem!" <David Wheeler> > > mobile: +49 (0) 179 29 28 834 > e-mail: michael.lindenau@xxxxxxxxxxxxxxxxxxxxxx > > ------------------------------------------------------- > Lvsungen+Ideen > > Alejandro Puskin No 1, Portal H, 5C > 29011 Malaga > ES - Espaqa > ------------------------------------------------------- > > This email is confidential. If you are not the intended > recipient, you must not disclose or use the information > contained in it. If you have received this mail in error, > please tell me immediately by return email and delete > the document.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] How to get a list of XPath ou, "Michael Lindenau (g | Thread | Re: [xsl] How to get a list of XPat, Robert Koberg |
[xsl] How to get a list of XPath ou, "Michael Lindenau (g | Date | [xsl] grouping nodes inside a new p, Andrew Male |
Month |