Re: [xsl] reg XSD generation using XSL

Subject: Re: [xsl] reg XSD generation using XSL
From: Silent lights <silentlights@xxxxxxxxxxx>
Date: Mon, 6 Dec 2010 16:42:10 +0000 (GMT)
Hi Geert,
The platform where I am working is based on X* and I have very
limited options 
to use Java or any other language...except XSLT. 

I did look
at Trang, looks promising.. but that could an option if nothing else 
thank you

----- Original Message ----
From: Geert Bormans
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Sent: Mon, 6
December, 2010 17:01:22
Subject: Re: [xsl] reg XSD generation using XSL

would you want to do that with XSLT?

use trang for a first stab at it
you can develop some XSLT
logic to twiddle the output of that to your 
be prepared to do
some manual stuff as well

At 16:57 6/12/2010, you wrote:
> Hi all, My
previous posts didnt get thru the I was not yet on the 
list.. hence I am posting it here. I am wondering if anyone had 
>attempted to
generate an schema from an input XML document. I am kind of stuck 
>up in this
and I am wondering if could get some help here. The Schemas has to be 
1.0 and generation code has to be written using XSL. I worked out a basic
>idea.. like 1) Open schema tag and check for name spaces 2) Check if current
>context is root,     2.1) is context root:- Print the element name.
>2.1.1) if children and attributes are present, the context is complex...else
>print context (single tag) as simple             2.1.2) If complex, print
>element names based on their types          check if
>children are complex in a for each loop and then goto 2.1.1
>close the complex tag..and check for attributes. 3) close the doc
with /schema I 
>came up with a basic code and it is working for xml with one
root element and 
>first children. If it goes towards grand children, I am
kind of printing out 
>same element types twice or more as they are visible in
previous siblings. I am 
>wondering what could be a generic solution here.
e.g. inbound xml <?xml 
>version='1.0' encoding="UTF-8"?> <catalog
cat="music">     <cd country="RSA">    
>     <title>Empire Burlesque</title>
<artist>Bob Dylan</artist>         
><price>10.90</price>     </cd>     <dd
county="UK">         <title1>Hide your 
>heart 4</title1>
<artist1>Bonnie Tyler</artist1>         
><price2>9.90</price2>     </dd>
<dc county="UK">         <title2>Hide your 
>heart 4</title2>
<artist2>Bonnie Tyler</artist2>         
><price2>9.90</price2>     </dc>
</catalog> The schema results in <xs:schema
>xmlns:xs=""; elementFormDefault="qualified"
>attributeFormDefault="unqualified">     <xs:element name="catalog">
><xs:complexType>             <xs:sequence>               <xs:element
>type="cdType"/>                 <xs:element name="dd"
>     <xs:element name="dc" type="dcType"/>
></xs:complexType>     </xs:element>
<xs:complexType name="cdType">         
><xs:sequence>             <xs:element
name="title" type="titleType"/>             
><xs:element name="artist"
type="artistType"/>             <xs:element 
>name="price" type="priceType"/>
</xs:sequence>         <xs:attribute 
>name="country" type="xs:string"/>
</xs:complexType>     <xs:simpleType 
<xs:restriction base="xs:string"/>     
></xs:simpleType>     <xs:simpleType
name="artistType">         <xs:restriction 
</xs:simpleType>     <xs:simpleType name="priceType">    
<xs:restriction base="xs:integer"/>     </xs:simpleType>     
name="ddType">         <xs:sequence>             <xs:element 
type="title1Type"/>             <xs:element name="artist1"
>type="artist1Type"/>             <xs:element name="price2"
>       </xs:sequence>         <xs:attribute
name="county" type="xs:string"/>     
></xs:complexType>     <xs:simpleType
name="title1Type">         <xs:restriction 
</xs:simpleType>     <xs:simpleType name="artist1Type">  
<xs:restriction base="xs:string"/>     </xs:simpleType>     
name="price2Type">         <xs:restriction base="xs:integer"/>
></xs:simpleType>     <xs:complexType name="dcType">         <xs:sequence>
>     <xs:element name="title2" type="title2Type"/>             <xs:element
>name="artist2" type="artist2Type"/>             <xs:element name="price2"
>type="price2Type"/>         </xs:sequence>         <xs:attribute
>type="xs:string"/>     </xs:complexType>     <xs:simpleType
>       <xs:restriction base="xs:string"/>
><xs:simpleType name="artist2Type">
<xs:restriction base="xs:string"/>     
></xs:simpleType>     <xs:simpleType
name="price2Type">         <xs:restriction 
</xs:simpleType> </xs:schema> where the simple type 
>price2Type is repeated
twice once processing dd and then dc. as I am processing 
>only the children
of that node context.  I am wondering what could be a generic 
>solution here
to avoid duplicates at this context node. thankyou Densil
XSL-List info and archive:
> To
unsubscribe, go to:
> or e-mail:
> --~--

Current Thread