xml editor

Products

Features

  EPUB
Supported platforms

Supports Windows 7 & Mac OS X Lion

Ready for XML Editor data server software
W3C Member

XSD from XML with multiple rows

This should cover W3C XML Schema, Relax NG and DTD related problems.

XSD from XML with multiple rows

Postby tsmith » Wed May 11, 2011 12:25 am

Is there a way to automatically generate XSD from the following XML which includes each row w/FieldName (not including the value attribute):

Code: Select all
<SelectResult>
  <Document DocumentType="Orders" DocumentKey="100000" Company="Z-Corp">
    <Header>
      <Row FieldName="Cust No." Value=""/>
      <Row FieldName="Order No." Value="2066"/>
      <Row FieldName="PO Number" Value="09-31"/>
      <Row FieldName="Ship To Address Line 1" Value="EMERALD POINTE GOLF CLUB"/>
      <Row FieldName="Ship To Address Line 2" Value="7000 HOLIDAY ROAD"/>
      <Row FieldName="Ship To Name" Value="LAKE LANIER ISLAND RESORT"/>
      <Row FieldName="Ship To Country" Value="United States of America"/>
      <Row FieldName="Ship To City" Value="BUFORD - LAKE LANIER ISLAND"/>
      <Row FieldName="Ship To Zip" Value="30518"/>
      <Row FieldName="Ship To State" Value="GA"/>
      <Row FieldName="Order Total" Value="1723.78"/>
      <Row FieldName="Ship Via" Value="TRUCK"/>
      <Row FieldName="Terms" Value="1.5% -10 - 30"/>
      <Row FieldName="Company Name" Value="Dewitt - Play"/>
      <Row FieldName="Company Address 1" Value="905 South Kingshighway"/>
      <Row FieldName="Company Address 2" Value=""/>
      <Row FieldName="Company City" Value="Sikeston"/>
      <Row FieldName="Company State" Value="MO"/>
      <Row FieldName="Company Zip code" Value="63801"/>
      <Row FieldName="Company Phone" Value="573-472-0048"/>
      <Row FieldName="Company Contact person" Value=""/>
      <Row FieldName="Ship To Contact Name" Value=""/>
      <Row FieldName="Ship To Phone" Value="256-766-2091"/>
      <Row FieldName="Ship Date" Value="11/19/2008"/>
    </Header>
  </Document>
</SelectResult>


Currently all I'm getting is the following:


Code: Select all
<xs:element name="Row">
    <xs:complexType>
      <xs:attribute name="FieldName" use="required"/>
      <xs:attribute name="Value" use="required"/>
    </xs:complexType>
  </xs:element>
tsmith
 
Posts: 1
Joined: Wed May 11, 2011 12:20 am

Re: XSD from XML with multiple rows

Postby george » Wed May 11, 2011 8:30 am

Hi,

You can pass the XML file though a simple XSLT like below that will remove the Value attribute, then pass that to the XML Schema instance generator:

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">

    <!-- copy -->
    <xsl:template match="node() | @*">
        <xsl:copy>
            <xsl:apply-templates select="node() | @*"/>
        </xsl:copy>
    </xsl:template>
   
    <!-- do nothing on Row/@Value -->
    <xsl:template match="Row/@Value"/>

</xsl:stylesheet>


Best Regards,
George
George Cristian Bina
george
Site Admin
 
Posts: 2033
Joined: Thu Jan 09, 2003 2:58 pm


Return to XML Schemas

Who is online

Users browsing this forum: No registered users and 0 guests

cron
XML Editor | XML Author | WYSIWYG Editors | Schema Editor | XSD Documentation | XSL/XSLT Editor | XQuery | XML Databases | SVN Client
© 2002-2011 SyncRO Soft Ltd. All rights reserved. | Sitemap | Privacy Policy | This website was created & generated with <oXygen/>® XML Editor