Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - XML Schema - 1 Element, Different Attributes, Can One Create Multiple Types? >Thread Next - Re: XML Schema - 1 Element, Different Attributes, Can One Create Multiple Types? Re: XML Schema - 1 Element, Different Attributes, Can One Create Multiple Types?To: NULL Date: 7/1/2009 2:58:00 PM Hm I've had a think about this, and it's not obvious that XSD contains
the feature you want (referencing the content of an attribute to
determine the validation rule required)
So it seems you may have to use a 2-pass approach.
A way to consider it with XSL, would be to validate your primary
document structure first. Then transforming the doc to include
xsi:type based on each matching Detail node's Name attribute; and
finally validating using the xsi:type specified
Or transforming the doc to a more element based structure
<Detail><Added>{value</Added></Detail> then validating the result of
that transformation using the Element name as usual.
Probably there's not much to choose in processing time, though I
consider transforming to Element based validation makes for easier
readability during testing.
In either case, it seems your input XML document is designed to
frustrate validation even though its a simple structure - if you have
any influence on the input document, I'd consider restructuring it.
HTH
Cheers - Neil
On Tue, 30 Jun 2009 13:28:46 -0700 (PDT), MaggotChild
<hsomob1999@y...> wrote:
>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.
>
>
>
------------------------------------------------
Digital Media MVP : 2004-2009
http://mvp.support.microsoft.com/mvpfaqs
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
