Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


keyref

From: "Marcus Smedman" <smedman@----.-->
To: <xmlschema-dev@--.--->
Date: 5/21/2004 11:24:00 AM
Hi, 

 

Here's a newbie question. I have an xml like this:

 

<?xml version="1.0" encoding="UTF-8"?>

<!--Sample XML file generated by XMLSPY v2004 rel. 2 U
(http://www.xmlspy.com)-->

<WWW xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="keyref_test.xsd">

       <AAA>

             <HHHs>

                    <HHH>

                          <JJJIDs>

                                 <JJJID>1</JJJID>

                                 <JJJID>2</JJJID>

                           </JJJIDs>

                    </HHH>

                    <HHH>

                           <JJJIDs>

                                 <JJJID>1</JJJID>

                                 <JJJID>2</JJJID>

                           </JJJIDs>

                    </HHH>

             </HHHs>

             <JJJs>

                    <JJJ JJJID="1">

                           <LLL>String</LLL>

                    </JJJ>

                    <JJJ JJJID="2">

                           <LLL>String</LLL>

                    </JJJ>

             </JJJs>

       </AAA>

       <BBB>

             <HHHs>

                    <HHH>

                           <JJJIDs>

                                 <JJJID>4</JJJID>

                                 <JJJID>5</JJJID>

                           </JJJIDs>

                    </HHH>

                    <HHH>

                           <JJJIDs>

                                 <JJJID>4</JJJID>

                                 <JJJID>5</JJJID>

                           </JJJIDs>

                    </HHH>

             </HHHs>

             <JJJs>

                    <JJJ JJJID="4">

                           <LLL>String</LLL>

                    </JJJ>

                    <JJJ JJJID="5">

                           <LLL>String</LLL>

                    </JJJ>

             </JJJs>

       </BBB>

</WWW>

 

 

It is validated against this schema:

 

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">

       <xs:element name="WWW">

             <xs:complexType>

                    <xs:sequence>

                           <xs:element name="AAA" type="CCC" minOccurs="0">

                                 <xs:key name="aJJJIDKey">

                                        <xs:selector xpath="JJJs/JJJ"/>

                                        <xs:field xpath="@JJJID"/>

                                 </xs:key>

                                 <xs:keyref name="aJJJIDRef"
refer="aJJJIDKey">

                                        <xs:selector
xpath="HHHs/HHH/JJJIDs/JJJID"/>

                                        <xs:field xpath="."/>

                                 </xs:keyref>

                           </xs:element>

                           <xs:element name="BBB" type="CCC" minOccurs="0">

                                 <xs:key name="bJJJIDKey">

                                        <xs:selector xpath="JJJs/JJJ"/>

                                        <xs:field xpath="@JJJID"/>

                                 </xs:key>

                                 <xs:keyref name="bJJJIDRef"
refer="bJJJIDKey">

                                        <xs:selector
xpath="HHHs/HHH/JJJIDs/JJJID"/>

                                        <xs:field xpath="."/>

                                 </xs:keyref>

                           </xs:element>

                    </xs:sequence>

             </xs:complexType>

       </xs:element>

       <xs:complexType name="CCC">

             <xs:sequence>

                    <xs:element ref="HHHs"/>

                    <xs:element ref="JJJs" minOccurs="0"/>

             </xs:sequence>

       </xs:complexType>

       <xs:element name="HHHs">

             <xs:complexType>

                    <xs:sequence maxOccurs="unbounded">

                           <xs:element name="HHH">

                                 <xs:complexType>

                                        <xs:sequence>

                                               <xs:element name="JJJIDs"
minOccurs="0">

                                                     <xs:complexType>

                                                            <xs:sequence
maxOccurs="unbounded">

 
<xs:element name="JJJID" type="xs:string" maxOccurs="unbounded"/>

                                                            </xs:sequence>

                                                     </xs:complexType>

                                               </xs:element>

                                        </xs:sequence>

                                 </xs:complexType>

                           </xs:element>

                    </xs:sequence>

             </xs:complexType>

       </xs:element>

       <xs:element name="JJJs">

             <xs:complexType>

                    <xs:sequence minOccurs="0" maxOccurs="unbounded">

                           <xs:element name="JJJ">

                                 <xs:complexType>

                                        <xs:sequence>

                                               <xs:element name="LLL"
type="xs:string"/>

                                        </xs:sequence>

                                        <xs:attribute name="JJJID"
type="xs:string" use="required"/>

                                 </xs:complexType>

                           </xs:element>

                    </xs:sequence>

             </xs:complexType>

       </xs:element>

</xs:schema>

 

 

What I want is to validate that all HHHs/HHH/JJJIDs exist in (the attribute)
the list of JJJs/JJJ/JJJID and it works. 

 

My question, is there a way to declare a key/keyref for JJJIDKey that works
for all CCC's. Above I've created a "aJJJIDKey", "bJJJIDKey" and I would
like to get around this.

 

Thanks

Marcus

 



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