Properly mapping an xml schema in Excel -
long time reader, first time poster. it's time mine site it's knowledge!
i'm trying set xml schema , populate data inside excel. i've made definitions complextypes because reused quite often. if reference type, example 3 times, inside excel maps type once.
i'm pretty new schemas boss wants me use them. other criticism appreciated.
xml schema:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/xmlschema"> <!-- type definitions (doorstyle, colour, accessory , tamarackmodel) --> <xsd:complextype name="doorstyle"> <xsd:sequence> <xsd:element name="style" type="xsd:string"/> <xsd:element name="wood" type="xsd:string"/> <xsd:element name="colour" type="xsd:string"/> <xsd:element name="imgsrc" type="xsd:string"/> </xsd:sequence> </xsd:complextype> <xsd:complextype name="colour"> <xsd:sequence> <xsd:element name="colour" type="xsd:string"/> <xsd:element name="wood" type="xsd:string"/> <xsd:element name="imgsrc" type="xsd:string"/> </xsd:sequence> </xsd:complextype> <xsd:complextype name="accessory"> <xsd:sequence> <xsd:element name="pdf" type="xsd:string"/> </xsd:sequence> </xsd:complextype> <xsd:complextype name="tamarackmodel"> <xsd:sequence> <xsd:element name="drawing" type="xsd:string"/> <xsd:element name="reversedrawing" type="xsd:string"/> <xsd:element name="pricesheet" type="xsd:string"/> </xsd:sequence> </xsd:complextype> <!-- group definitions (doorstyles, colours, accessories , tamarackmodels) --> <xsd:element name="doorstyles"> <xsd:complextype> <!-- <xsd:attribute name="url" type="xsd:string" fixed="http://www.muskokacabco.com/muskoka-kitchens-gallery-door-styles.html"/> --> <xsd:sequence> <xsd:element name="doorstyle" type="doorstyle"/> <xsd:element name="doorstyle" type="doorstyle"/> <xsd:element name="doorstyle" type="doorstyle"/> </xsd:sequence> </xsd:complextype> </xsd:element> <xsd:element name="colours"> <xsd:complextype> <!-- xsd:attribute name="url" type="xsd:string" fixed="http://www.muskokacabco.com/muskoka-kitchens-gallery-stain-colours.html"/> --> <xsd:sequence> <xsd:element name="colour" type="colour"/> <xsd:element name="colour" type="colour"/> <xsd:element name="colour" type="colour"/> </xsd:sequence> </xsd:complextype> </xsd:element> <xsd:element name="accessories"> <xsd:complextype> <!-- <xsd:attribute name="url" type="xsd:string" fixed="http://www.muskokacabco.com/muskoka-kitchens-accessories.html"/> --> <xsd:sequence> <xsd:element name="accessory" type="accessory"/> <xsd:element name="accessory" type="accessory"/> <xsd:element name="accessory" type="accessory"/> </xsd:sequence> </xsd:complextype> </xsd:element> <xsd:element name="tamarackmodels"> <xsd:complextype> <!-- <xsd:attribute name="url" type="xsd:string" fixed="http://www.muskokacabco.com/muskoka-kitchens-tamarack-models.html"/> --> <xsd:sequence> <xsd:element name="tamarackmodel" type="tamarackmodel"/> <xsd:element name="tamarackmodel" type="tamarackmodel"/> <xsd:element name="tamarackmodel" type="tamarackmodel"/> </xsd:sequence> </xsd:complextype> </xsd:element> <!-- overall structure --> <xsd:element name="muskokasite"> <!-- <xsd:attribute name="url" type="xsd:string" fixed="http://www.muskokacabco.com"/> --> <xsd:complextype> <xsd:sequence> <xsd:element ref="doorstyles"/> <xsd:element ref="colours"/> <xsd:element ref="accessories"/> <xsd:element ref="tamarackmodels"/> </xsd:sequence> </xsd:complextype> </xsd:element> </xsd:schema>
so reference each type 3 times, in excel lets me map each type once if choose root. have loved include screenshot apparently new users can't that...
so apparently "maxoccurs" attribute on elements defaults one. set "unbounded" , works now.
<xsd:group name="doorstyles"> <xsd:sequence> <xsd:element ref="doorstyle" maxoccurs="unbounded"/> </xsd:sequence> </xsd:group>
Comments
Post a Comment