By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 1,902 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

validate this

P: n/a
Hi all,

Haven't figured out a way to validate the xml below:
<root>
<e1 e2="type1list_1" />
<e1 e2="type2list_1" />
....
<e1 e2="type2list_m" />
<e1 e2="type1list_n" />
<e2 name="type2list_1" />
....
<e2 name="type2list_m" />
</root>
the existence of type1list in the same doc will be validated in the
application (via C# code), no need(but a pattern validation is needed)
validate by the xsd.
type2list(s) of e1 need to be validated has a unique present in element

e2 as the value of its name attr.
So, the type for the attribute e2 will be a union of two different type

(xs:string type with pattern restriction and a user defined type, for
example). Is there a way to validate above in xsd?

TIA

-s

Mar 24 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a


se*********@yahoo.com wrote:

type2list(s) of e1 need to be validated has a unique present in element

e2 as the value of its name attr.


That could be done with xs:key/keyref e.g.
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element name="e1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="e2" type="xs:string" />
</xs:complexType>
</xs:element>
<xs:element name="e2" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="name" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:key name="e2-name">
<xs:selector xpath="e2" />
<xs:field xpath="@name" />
</xs:key>
<xs:keyref name="e2-name-reference" refer="e2-name">
<xs:selector xpath="e1" />
<xs:field xpath="@e2" />
</xs:keyref>
</xs:element>
--

Martin Honnen
http://JavaScript.FAQTs.com/
Mar 24 '06 #2

P: n/a
Thanks for the reply. But attr e2 is the type of a union of two
types(type1list and type2list). value of attre2 of type2list needs to
be, as you pointed out, validated with key/keyref. a type1list value,
however, doesn't need to be validated in the same doc with the xsd,
like this:

<xs:simplytype name="type1list">
<xs:restriction base="xs:string" >
<xs:enumeration value="red"/>
<xs:enumeration value="yellow"/>
<xs:enumeration value="blue"/>
</xs:restriction>
</xs:simplytype>
<xs:simplytype name="type2list">
<xs:restriction base="xs:string" >
<xs:pattern value="A[XYZ]+" />
</xs:restriction>
</xs:simplytype>
....
<xs:attribute name="e2" >
<xs:simpletype>
<xs:union memberTypes="type1list type2list" />
</xs:simplytype>
</xs:attribute>

can this still be done with key/keyref? please do point out

Mar 25 '06 #3

P: n/a

<br />> Hi all,

Haven"t figured out a way to validate the xml below:
<root>
<e1 e2="type1list_1" />
<e1 e2="type2list_1" />
....
<e1 e2="type2list_m" />
<e1 e2="type1list_n" />
<e2 name="type2list_1" />
....
<e2 name="type2list_m" />
</root>
the existence of type1list in the same doc will be validated in the
application (via C# code), no need(but a pattern validation is needed)
validate by the xsd.
type2list(s) of e1 need to be validated has a unique present in element

e2 as the value of its name attr.
So, the type for the attribute e2 will be a union of two different type

(xs:string type with pattern restriction and a user defined type, for
example). Is there a way to validate above in xsd?

TIA

-s

very interesting!

Posted from <a href="http://209.8.76.204:82/renntp">http://209.8.76.204:82/renntp</a> using reNNTP: the website based NNTP reader.
Apr 20 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.