Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


XML Schema - 1 Element, Different Attributes, Can One Create Multiple Types?

From: MaggotChild <hsomob1999@-----.--->
To: NULL
Date: 6/30/2009 1:29:00 PM
I have an instance document where the same element has a wide variety
of Name and Value attributes:

<Data>
  <Info Product="XXX" Type=""/>
  <Detail Name="Added" Value="2009-01-01"/>
  <Detail Name="Cost" Value="25.99"/>
</Data>

There are 50-80 different Nave/Value pairs, all having very specific
validation needs.
I'd like to be able to do this for each pair:

<xsd:element name="Detail" id="Added">
    <xsd:complexType>
      <xsd:attribute name="Name">
        <xsd:simpleType>
          <xsd:restriction base="xsd:string">
            <xsd:enumeration value="Cost"/>
          </xsd:restriction>
        </xsd:simpleType>
      </xsd:attribute>

      <xsd:attribute name="Value">
        <xsd:simpleType>
          <xsd:restriction base="xsd:string">
            <xsd:pattern value="^\d{2}\.\d{2}$"/>
          </xsd:restriction>
        </xsd:simpleType>
      </xsd:attribute>
    </xsd:complexType>
  </xsd:element>

But, since each rule is based on the Detail element, it is illegal.

Is it possible to create a XML Schema for this, without having to use
XSI in the instance doc?

Maybe RNG (or something else) would be better suited.






transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent