XmlGrid Users Forum
2012-05-30 18:15:03 XmlGrid allows you to easily generate an XSD (schema) from an XML document. In the following example, we generate an XSD from a google XML sitemap. 

The sitemap.xml: 
__code__
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" >
          <!-- created with Free Online Sitemap Generator www.xml-sitemaps.com -->
       <url>
              <loc>http://xmlgrid.net/</loc>
              <lastmod>2012-05-19T01:28:45+00:00</lastmod>
              <changefreq>daily</changefreq>
          </url>
       <url>
              <loc>http://xmlgrid.net/demo.html</loc>
              <lastmod>2012-03-17T15:19:46+00:00</lastmod>
              <changefreq>daily</changefreq>
          </url>
</urlset>

__code__

the generated XSD:

__code__
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" >
          <!-- XML Schema Generated from XML Document on Wed May 30 2012 18:06:13 GMT-0400 (Eastern Daylight Time) -->
          <!-- with XmlGrid.net Free Online Service http://xmlgrid.net -->
       <xs:element name="urlset" >
              <xs:complexType>
                     <xs:sequence>
                            <xs:element name="url" maxOccurs="unbounded" >
                                   <xs:complexType>
                                          <xs:sequence>
                                                 <xs:element name="loc" type="xs:string" />
                                                 <xs:element name="lastmod" type="xs:dateTime" />
                                                 <xs:element name="changefreq" type="xs:string" />
                                             </xs:sequence>
                                      </xs:complexType>
                               </xs:element>
                        </xs:sequence>
                     <xs:attribute name="xmlns" type="xs:string" />
                     <xs:attribute name="xmlns:xsi" type="xs:string" />
                     <xs:attribute name="xsi:schemaLocation" type="xs:string" />
                 </xs:complexType>
          </xs:element>
 </xs:schema>
__code__

In this example, <lastmod>2012-05-19T01:28:45+00:00</lastmod> was correctly detected as "xs:dateTime" data type.
;3424;2012-05-30 18:15:03__s__XmlGrid allows you to easily generate an XSD (schema) from an XML document. In the following example, we generate an XSD from a google XML sitemap. 

The sitemap.xml: 
__code__
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" >
          <!-- created with Free Online Sitemap Generator www.xml-sitemaps.com -->
       <url>
              <loc>http://xmlgrid.net/</loc>
              <lastmod>2012-05-19T01:28:45+00:00</lastmod>
              <changefreq>daily</changefreq>
          </url>
       <url>
              <loc>http://xmlgrid.net/demo.html</loc>
              <lastmod>2012-03-17T15:19:46+00:00</lastmod>
              <changefreq>daily</changefreq>
          </url>
</urlset>

__code__

the generated XSD:

__code__
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" >
          <!-- XML Schema Generated from XML Document on Wed May 30 2012 18:06:13 GMT-0400 (Eastern Daylight Time) -->
          <!-- with XmlGrid.net Free Online Service http://xmlgrid.net -->
       <xs:element name="urlset" >
              <xs:complexType>
                     <xs:sequence>
                            <xs:element name="url" maxOccurs="unbounded" >
                                   <xs:complexType>
                                          <xs:sequence>
                                                 <xs:element name="loc" type="xs:string" />
                                                 <xs:element name="lastmod" type="xs:dateTime" />
                                                 <xs:element name="changefreq" type="xs:string" />
                                             </xs:sequence>
                                      </xs:complexType>
                               </xs:element>
                        </xs:sequence>
                     <xs:attribute name="xmlns" type="xs:string" />
                     <xs:attribute name="xmlns:xsi" type="xs:string" />
                     <xs:attribute name="xsi:schemaLocation" type="xs:string" />
                 </xs:complexType>
          </xs:element>
 </xs:schema>
__code__

In this example, <lastmod>2012-05-19T01:28:45+00:00</lastmod> was correctly detected as "xs:dateTime" data type.
__s__~u=Zac~site=NULL__s__xml to xsd generator online__s____m__2012-09-21 09:04:03__s__<?xml version="1.0" ?>
<articles xmlns:perform:articles="http://www.perform:articlegroup.com/ns/artilces/artilceList"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.perform:articlegroup.com/ns/artilces/artilceList http://localhost/schema/articles/xsd/1.0/articles.xsd">
    <article>
        <uuid>1udr7cphvzm611fng5yuwh0cwa</uuid>
        <partnerId>4166bd34-02d9-4bfd-959a-f5ee296673d3</partnerId>
        <headline>Some headline of article</headline>
        <seoPageUrl>http://domain.co.uk/article/1udr7cphvzm611fng5yuwh0cwa
        </seoPageUrl>
        <teaser>Some teaser of article</teaser>
        <body>Body of article</body>
        <byLine>Peter Vavra</byLine>
        <createdDate>2012-07-12T00:15:38Z</createdDate>
        <expireDate>2012-07-15T00:15:38Z</expireDate>
        <language>en</language>
        <lastUpdateDate>2012-07-12T00:15:38Z</lastUpdateDate>
        <publishedDate>2012-07-12T02:15:38Z</publishedDate>
        <!-- Below information will be added to the request if it exists for the
            article -->
        <keywords>
            <keyword>
                TestKeyword
            </keyword>
        </keywords>
        <categories>
            <category>
                <id>123</id>
            </category>
            <category>
                <id>12</id>
            </category>
        </categories>
        <images>
            <image>
                <type>gallery/Headline</type>
                <UUID>3x23eaf00fd2xc545e22631</UUID>
            </image>
        </images>
        <relatedarticles>
            <relatedarticle>
                <type>contex type</type>
                <relatedArtilceUUID>
                    1udr7cphvzm611fng5yuwh0cwdd
                </relatedArtilceUUID>
            </relatedarticle>
        </relatedarticles>
        <translations>
            <translation>
                <langugage>en
                </langugage>
                <uuid>227eaf00fd246419529d5545e22631</uuid>
            </translation>
        </translations>
    </article>
</articles>
__s__~u=priya~site=NULL__s__ __s____m__2012-10-23 10:07:59__s__
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- ESI Comments: 
- use CamelCase with upper case initial letter for all element names 
- use camelCase with lower case initial letter for all attribute names
- avoid generic names like "item", use domain specific elements instead
- don't forget to add assets:
<Assets main="urn:esvc:car:asset:12345">
<Asset ref="urn:esvc:car:asset:12345" view="3/4" type="packshot" />
..
</Assets> 
-->
<!-- #1 this file is monolingual although some fields are translated ...  -->
<!-- 
#1 ESI: Multilingual fields => Does the translated fields are available in several languages
? What do we have in this case? Attribute with language (<description lang="fr">, <description lang="en">) 
-->

<!-- #2 many of these fields have internal codes that can be added if relevant for other systems -->
<!-- #2 ESI: 
Add the date of modification in Product element as an attribute, same as what we have for asset (<Product id="1234" mod="201208011200">)
Idem for for products list (<Products mod="201208011200") in order to be able to query products modified since last query.
-->
<Product id="CRHP1234567" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="2012_10_22_Proposition_XSD_PIM_Product.xsd">
<Properties>
<!-- #3 Example of a text (code/value on our side) -->
<Collection>Name of the collection</Collection>
<SubCollection>Name of the sub collection</SubCollection>
<!-- #4 Example of a textarea with CDATA to preserve white spaces -->
<ProductName><![CDATA[name of the product,
as defined with eventually CRLF]]></ProductName>
<!-- #5 Example of a BOOLEAN : TRUE/FALSE or blank -->
<LimitedEdition>TRUE</LimitedEdition>
<WmfShape>Round</WmfShape>
<!-- #6 Example of a NUMBER -->
<Number>4</Number>
<!-- #7 Example of a DECIMAL (do you handle the precision or do you want it as a formatted text ?) 
may we have some unit problems ? should we convert ? (this needs to be checked attribute by attribute)
-->
<!-- I rather prefer to have it's decimal value. Like that you can convert it to decimal directly.
<xs:element name="diameter" type="xs:decimal"/> 
The the following declarations can be accepted:
<diameter>3.0018</diameter> 
<diameter>3.0</diameter> 
-->
<Diameter>3.0018</Diameter>
<!-- #8 What do we do when an attribute is empty or does not apply ? like this or hidden ? -->
<!-- #8 ESI: Remove hidden elements-->
  <!--  <length /> -->
<!-- #9 example for multi-valued list -->
<!-- #9 ESI: Regarding the multivalued lists (e.g. "Colors") I am not sure if the values are really arbitrary values or an enumeration. 
Should this be part of the schema definition?
If so, perhaps we should use element names to indicate color?
  In any case I do not like the generic "item" element; better call it "Color".  -->
<Colors>
<Color code="blue">Blue</Color>
<Color code="red">Red</Color>
<Color code="green">Green</Color>
</Colors>
<!-- #10 WFC are a list of pair (type/position) attached not to the movement but to the watch (!) -->
<!-- #10 ESI: You can add more movement function -->
<MovementFunction>
<Type>Moon Phase</Type>
<Position>3h00</Position>
</MovementFunction>
<MovementFunction>
<Type>Other Type</Type>
<Position>4h00</Position>
</MovementFunction>
<!-- #11 nothing was found in the specs to actually access the docuemente, 
a 3rd Web Service may be necessary to download the document from the ID presented here
-->
<Documents>
<!-- #11 ESI - Can we convert this to a morea readable business Name
W...P...A...D...F...U..WatchDocument
-->
<WPADFUWatchDocument>
<Document id="219x12256">
<Length>2000000</Length>
<LastModified>.......</LastModified>
</Document>
</WPADFUWatchDocument>
</Documents>


</Properties>
<!-- #12 Issue here : the proposed tree comes from Matrix and no order is guaranteed. 
in essence, that means you can have WATCH > CASE > MOVEMENT or WATCH > CASE or WATCH > MOVEMENT
-->
<!-- ESI: The "Properties", "Components" and "Component" elements are more complicated...
I think we should keep them in the same spirit as we have a "Product" and not a "Watch" element. On the other hand... 
it is not very consistent with the actual property names (modeled as elements) and not in the spirit of a DSL... 
-->
<Components>
<!-- #13 Be careful, we may have more than one movement/bracelet/dial in a watch -->
<Component>
<Properties></Properties>
</Component>
<Component type="movement" id="CRMX123456a">
<Properties>
<Energy>Automatic</Energy>
</Properties>
</Component>
<Component type="movement" id="CRMX123456b">
<Properties>
<Energy>Automatic</Energy>
</Properties>
</Component>
<Component type="case">
<Properties>
<OtherProp>...</OtherProp>
</Properties>
<Components>
<Component type="back" id="CRMX000001">
<Properties>
</Properties>
</Component>
</Components>
</Component>
</Components>
<!-- ASSETS  -->
<Assets main="urn:esvc:car:asset:12345">
<Asset ref="urn:esvc:car:asset:12345" view="3/4" type="packshot" />
</Assets>

</Product>
__s__~u=asas~site=NULL__s__ __s____m__2012-12-18 01:53:59__s__<score seq="1" type="NRG" numeric="$267455$">  <option lbound="" ubound="0">10</option> <option lbound="0" ubound=""> <score seq="1" type="NRG" numeric="$257555$">  <option lbound="" ubound="0">0</option> <option lbound="0" ubound="5"> <score seq="1" type="NRG" evaluate="($267455$/$257555$)*100">  <option lbound="" ubound="20">7</option>  <option lbound="20" ubound="40">4</option>  <option lbound="40" ubound="">0</option>          </score> </option> <option lbound="6" ubound=""> <score seq="1" type="NRG" evaluate="($267455$/$257555$)*100">  <option lbound="" ubound="10">7</option>  <option lbound="10" ubound="30">4</option>  <option lbound="30" ubound="">0</option>          </score> </option> </score> </option></score>__s__~u=test~site=NULL__s__ __s____m__2013-02-07 14:56:58__s__
<?xml version="1.0"?>
<sched:HolidaySchedules xmlns:sched="urn:or-HolidaySchedules">
  <sched:HolidaySchedule xmlns:sched="urn:or-HolidaySchedule">
    <sched:scheduleId>0</sched:scheduleId>
    <sched:scheduleName>NYC</sched:scheduleName>
    <sched:scheduleDescr>New York City / Banking Holidays</sched:scheduleDescr>
    <sched:weekend>65</sched:weekend>
    <hol:HolidayDetail xmlns:hol="urn:or-HolidayDetail">
      <hol:holidayName></hol:holidayName>
      <hol:holidayDate>19880101T000000</hol:holidayDate>
      <hol:holidayActive>Yes</hol:holidayActive>
      <hol:lastUpdate>20130126T000000</hol:lastUpdate>
    </hol:HolidayDetail>
    <hol:HolidayDetail xmlns:hol="urn:or-HolidayDetail">
      <hol:holidayName></hol:holidayName>
      <hol:holidayDate>19880118T000000</hol:holidayDate>
      <hol:holidayActive>Yes</hol:holidayActive>
      <hol:lastUpdate>20130126T000000</hol:lastUpdate>
    </hol:HolidayDetail>
    <hol:HolidayDetail xmlns:hol="urn:or-HolidayDetail">
      <hol:holidayName></hol:holidayName>
      <hol:holidayDate>19880215T000000</hol:holidayDate>
      <hol:holidayActive>Yes</hol:holidayActive>
      <hol:lastUpdate>20130126T000000</hol:lastUpdate>
    </hol:HolidayDetail>
  </sched:HolidaySchedule>
</sched:HolidaySchedules>
__s__~u=gOPAL~site=NULL__s__ __s____m__2013-02-26 12:51:36__s__<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<lastUpdate>2013-01-30 14:12:25</lastUpdate>
__s__~u=test~site=NULL__s__ __s____m__

Best view with Google Chrome