2012-06-08 34 views
1

長時間閱讀器,第一次張貼海報。現在是時候挖掘這個網站的所有知識!正確地在Excel中映射xml架構

我想設置一個xml模式並在excel中填充數據。我已經爲一些complexTypes做了一些定義,因爲它們會經常被重用。如果我在Excel中引用類型,例如3次,它只會將類型映射一次。

我對模式很陌生,但我的老闆想讓我使用它們。任何其他批評將不勝感激。

XML模式:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 


<!-- Type Definitions (DoorStyle, Colour, Accessory and 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 and 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> 

所以我引用的每個類型的3倍左右,但在Excel中,只讓我一次映射每一種類型,如果我選擇爲根。我本來希望包括一個截圖,但顯然新用戶不能這樣做...

+0

什麼問題?這些與Excel有什麼關係?請閱讀[常見問題]和[問]發佈準則。 –

+0

我正在導入一個XSD架構,然後導出到xml。問題是如何對元素進行多次引用。我會發布修復,但StackOverflow顯然非常限制新手。不管怎麼說,還是要謝謝你 –

回答

1

因此顯然,元素上的「maxOccurs」屬性默認爲1。我將它設置爲「無界限」,現在可以工作。

<xsd:group name="DoorStyles"> 
     <xsd:sequence> 
     <xsd:element ref="DoorStyle" maxOccurs="unbounded"/> 
     </xsd:sequence> 
    </xsd:group>