I don't remember the exact error msg from XMLbeans.
But after doing further research, here's what I found
an issue with the schema below. I guess it's a bug
with XMLBeans if it validates the instance with no
error.
I think the following Key definition is not valid:
<xs:key name="sgKey">
<xs:selector xpath="./owner"/>
<xs:field xpath="sg/name"/>
<xs:field xpath="@id"/>
<xs:field xpath="@name"/>
</xs:key>
because, it allows multiple 'sg/name' elements per
Selected 'owner'.
i.e.
<sgs>
<owner id="a" name="b">
<sg>
<name>sg1</name>
<description/>
</sg>
<sg>
<name>sg2</name>
<description/>
</sg>
</owner>
.....
The above XML instance must be invalid w.r.t Key
constraint definition. I am still trying to figure out
how to model it differently.
-D
--- Jacob Danner <[EMAIL PROTECTED]> wrote:
> Hi Samy,
> I'm not seeing any validation issues from this when
> I use the instance and
> the xsd you posted.
> What is the xmlbeans error you are seeing?
> I've generated an instance using xmlbeans xsd2inst
> tool and attached it in
> case you want another reference. The instance
> validates to the xsd also.
>
> Best of luck,
> -jacobd
>
> On Dec 4, 2007 5:23 PM, dave <[EMAIL PROTECTED]>
> wrote:
>
> >
> > I am stuck with a problem where Validation
> > of constraints(keyref) fails saying it can't find
> the
> > matching key values. But, I do have the Key values
> > present in my XML instance. I also think I have
> taken
> > care of defining these Key and Keyref with proper
> > scoping (in my case, KeyRef is in the parent scope
> of
> > Key constraint definition).
> >
> > Here's the specific constraint Validation error
> > message from XmlSpy (similar issue with XmlBeans):
> > "Undefined values for keyref identity constraint
> > "stSgRef" - the values referred to by the field
> > selector must match an existing unique/key value"
> >
> > Here's my XSD:
> > <?xml version="1.0" encoding="UTF-8"?>
> > <!-- edited with XMLSpy v2008 sp1
> > (http://www.altova.com) by spy (spy) -->
> > <!--W3C Schema generated by XMLSpy v2008
> > (http://www.altova.com)--
> <http://www.altova.com%29-->>
> > <xs:schema
> targetNamespace="http://www.xxx.com/1.1"
> > xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > xmlns="http://www.xxx.com/1.1"
> > elementFormDefault="qualified"
> > attributeFormDefault="unqualified" version="1.0">
> > <xs:complexType name="SgType"
> abstract="false"
> > mixed="false">
> > <xs:sequence minOccurs="0">
> > <xs:element name="name"
> type="xs:string"
> > nillable="false"/>
> > <xs:element
> name="description" type="xs:string"
> > minOccurs="0"/>
> > </xs:sequence>
> > </xs:complexType>
> > <xs:complexType name="ServiceType"
> abstract="false"
> > mixed="false">
> > <xs:sequence>
> > <xs:element
> name="description" default="None"
> > nillable="true" minOccurs="0">
> > <xs:simpleType>
> >
> <xs:restriction base="xs:string">
> >
> <xs:maxLength value="100"
> > fixed="false"/>
> >
> </xs:restriction>
> > </xs:simpleType>
> > </xs:element>
> > <xs:element
> name="sgReference"
> > type="GenericReference" nillable="false"
> > maxOccurs="unbounded"/>
> > </xs:sequence>
> > <xs:attribute name="id"
> type="xs:string"
> > use="required"/>
> > </xs:complexType>
> > <xs:complexType name="OwnerType"
> abstract="false"
> > mixed="false">
> > <xs:sequence>
> > <xs:element
> name="emailAddress" nillable="false"
> > minOccurs="0">
> > <xs:simpleType>
> >
> <xs:restriction base="xs:string"/>
> > </xs:simpleType>
> > </xs:element>
> > <xs:element name="url"
> nillable="false"
> > minOccurs="0">
> > <xs:simpleType>
> >
> <xs:restriction base="xs:string"/>
> > </xs:simpleType>
> > </xs:element>
> > </xs:sequence>
> > <xs:attributeGroup
> ref="OwnerReference"/>
> > </xs:complexType>
> > <xs:element name="data" abstract="false"
> > nillable="false">
> > <xs:annotation>
> > <xs:documentation>Root
> Element</xs:documentation>
> > </xs:annotation>
> > <xs:complexType mixed="false">
> > <xs:sequence>
> > <xs:element
> name="owners">
> >
> <xs:complexType>
> >
> <xs:sequence>
> >
> <xs:element
> > name="owner" type="OwnerType"
> > maxOccurs="unbounded"/>
> >
> </xs:sequence>
> >
> </xs:complexType>
> > </xs:element>
> > <xs:element
> name="sgs" minOccurs="0">
> >
> <xs:complexType>
> >
> <xs:sequence>
> >
> <xs:element
> > name="owner" maxOccurs="unbounded">
> >
> > <xs:complexType>
> >
> > <xs:sequence>
> >
> > <xs:element name="sg" type="SgType"
> > maxOccurs="unbounded"/>
> >
> > </xs:sequence>
> >
> > <xs:attributeGroup ref="OwnerReference"/>
> >
> > </xs:complexType>
> >
> <xs:key
> > name="sgKey">
> >
> > <xs:selector xpath="./owner"/>
> >
> > <xs:field xpath="sg/name"/>
> >
> > <xs:field xpath="@id"/>
> >
> > <xs:field xpath="@name"/>
> >
> </xs:key>
> >
> </xs:element>
> >
> </xs:sequence>
> >
> </xs:complexType>
> > </xs:element>
> > <xs:element
> name="sts" minOccurs="0">
> >
> <xs:complexType>
> >
> <xs:sequence>
> >
> <xs:element
> > name="owner" maxOccurs="unbounded">
> >
> > <xs:complexType>
> >
> > <xs:sequence>
> >
> > <xs:element name="st" type="ServiceType"
> > maxOccurs="unbounded"/>
> >
> > </xs:sequence>
> >
> > <xs:attribute name="id" type="xs:string"
> > use="required"/>
> >
> > <xs:attribute name="name" type="xs:string"
> > use="required"/>
> >
> > </xs:complexType>
> >
> <xs:key
> > name="stKey">
> >
> > <xs:selector xpath="./owner"/>
> >
> > <xs:field xpath="@id"/>
> >
> > <xs:field xpath="@name"/>
> >
> > <xs:field xpath="st/@id"/>
> >
> </xs:key>
> >
> </xs:element>
> >
> </xs:sequence>
> >
> </xs:complexType>
> > </xs:element>
> > </xs:sequence>
> > <xs:attribute
> name="schemaVersion" type="xs:string"
> > use="required">
> > <xs:annotation>
> >
> <xs:documentation>schema
> > version</xs:documentation>
> > </xs:annotation>
> > </xs:attribute>
> > </xs:complexType>
> > <xs:keyref name="sgOwnerRef"
> refer="ownerKey">
> > <xs:selector
> xpath="./sgs/owner"/>
> > <xs:field xpath="@id"/>
> > <xs:field xpath="@name"/>
> > </xs:keyref>
> > <xs:key name="ownerKey">
> > <xs:selector
> xpath="./owners/owner"/>
> > <xs:field xpath="@id"/>
> > <xs:field xpath="@name"/>
> > </xs:key>
> > <xs:keyref name="stOwnerRef"
> refer="ownerKey">
> > <xs:selector
> xpath="./sts/owner"/>
> > <xs:field xpath="@id"/>
> > <xs:field xpath="@name"/>
> > </xs:keyref>
> > <xs:keyref name="stSgRef"
> refer="sgKey">
> > <xs:selector
> xpath="./sts/owner/st/sgReference"/>
> > <xs:field xpath="name"/>
> > <xs:field
> xpath="owner/@id"/>
> > <xs:field
> xpath="owner/@name"/>
> > </xs:keyref>
> > </xs:element>
> > <xs:attributeGroup name="OwnerReference">
> > <xs:attribute name="id"
> type="xs:string"
> > use="required"/>
> > <xs:attribute name="name"
> type="xs:string"
> > use="required"/>
> > </xs:attributeGroup>
> > <xs:complexType name="GenericReference">
> > <xs:sequence>
> > <xs:element name="name"
> type="xs:string"/>
> > <xs:element name="owner">
> > <xs:complexType>
> >
> <xs:attributeGroup
> > ref="OwnerReference"/>
> > </xs:complexType>
> > </xs:element>
> > </xs:sequence>
> > </xs:complexType>
> > </xs:schema>
> >
> >
> >
> > Here is my XML instance which has the validation
> > error:
> > <?xml version="1.0" encoding="UTF-8"?>
> > <!--Sample XML file generated by XML Spy v4.3 U
> > (http://www.xmlspy.com)--
> <http://www.xmlspy.com%29-->>
> > <data xmlns="http://www.xxx.com/1.1"
> >
>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > xsi:schemaLocation="http://www.xxx.com/1.1
> > sample.xsd" schemaVersion="">
> > <owners>
> > <owner id="a" name="b">
> > <emailAddress/>
> > <url/>
> > </owner>
> > <owner id="c" name="d">
> > <emailAddress/>
> > <url/>
> > </owner>
> > </owners>
> > <sgs>
> > <owner id="a" name="b">
> > <sg>
> > <name>sg1</name>
> > <description/>
> > </sg>
> > <sg>
> > <name>sg2</name>
> > <description/>
> > </sg>
> > </owner>
> > <owner id="c" name="d">
> > <sg>
> > <name>sg1</name>
> > <description/>
> > </sg>
> > <sg>
> > <name>sssg</name>
> > <description/>
> > </sg>
> > </owner>
> > </sgs>
> > <sts>
> > <owner id="a" name="b">
> > <st id="ccc">
> > <description/>
> > <sgReference>
> >
> <name>sg1</name>
> > <owner
> id="c" name="d"/>
> > </sgReference>
> > <sgReference>
> >
> <name>sg2</name>
> > <owner
> id="a" name="b"/>
> > </sgReference>
> > </st>
> > <st id="ddd">
> > <description/>
> > <sgReference>
> >
> <name>sg1</name>
> > <owner
> id="c" name="d"/>
> > </sgReference>
> > <sgReference>
> >
> <name>sg1</name>
> > <owner
> id="a" name="b"/>
> > </sgReference>
> > </st>
> > </owner>
> > <owner id="c" name="d">
> > <st id="re">
> > <description/>
> > <sgReference>
> >
> <name>sssg</name>
> > <owner
> id="c" name="d"/>
> > </sgReference>
> > <sgReference>
> >
> <name>sssg</name>
> > <owner
> id="c" name="d"/>
> > </sgReference>
> > </st>
> > <st id="ru">
> > <description/>
> > <sgReference>
> >
> <name>sg1</name>
> > <owner
> id="a" name="b"/>
> > </sgReference>
> > <sgReference>
> >
> <name>sssg</name>
> > <owner
> id="c" name="d"/>
> > </sgReference>
> > </st>
> > </owner>
> > </sts>
> > </data>
> >
> >
> >
> >
> > Here is my sample Key value in the above XML
> > instance:
> > <sgs>
> > <owner id="a" name="b">
> > <sg>
> > <name>sg1</name>
> > <description/>
> > </sg>
> > ....
> > Key { sg/name, @id, @name} => {sg1,a,b}
> > This Key is defined at the 'owner' scope.
> >
> > My sample KeyRef in Xml instance:
> > <sts>
> > <owner id="c" name="d">
> > <st id="ru">
> > <sgReference>
> > <name>sg1</name>
> > <owner id="a" name="b"/>
> > </sgReference>
> > .....
> > So, I do have these KeyRef values(sg1,a,b) in
> the
> > Key value. Why am I still getting this validation
> > error?
> >
> > Unfortunately, I need to keep this design where
> > "Owner" element is a container holding hundreds of
> > "st" or "sg". And there can be hundreds of "Owner"
> > elements.
> >
> > Appreciate any tips. It may be nothing to with
> typical
> > namespace issue.
> >
> > -samy
> >
> >
> >
> >
>
____________________________________________________________________________________
> > Looking for last minute shopping deals?
> > Find them fast with Yahoo! Search.
> >
>
http://tools.search.yahoo.com/newsearch/category.php?category=shopping
> >
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> > For additional commands, e-mail:
> [EMAIL PROTECTED]
> >
> >
> > <ns:data schemaVersion="string"
> xmlns:ns="http://www.xxx.com/1.1">
> <ns:owners>
> <!--1 or more repetitions:-->
> <ns:owner id="string" name="string">
> <!--Optional:-->
> <ns:emailAddress>string</ns:emailAddress>
> <!--Optional:-->
> <ns:url>string</ns:url>
> </ns:owner>
> </ns:owners>
> <!--Optional:-->
> <ns:sgs>
> <!--1 or more repetitions:-->
> <ns:owner id="string" name="string">
> <!--1 or more repetitions:-->
> <ns:sg>
> <ns:name>string</ns:name>
> <!--Optional:-->
> <ns:description>string</ns:description>
> </ns:sg>
> </ns:owner>
> </ns:sgs>
> <!--Optional:-->
> <ns:sts>
> <!--1 or more repetitions:-->
> <ns:owner id="string" name="string">
> <!--1 or more repetitions:-->
> <ns:st id="string">
> <!--Optional:-->
> <ns:description>string</ns:description>
> <!--1 or more repetitions:-->
> <ns:sgReference>
> <ns:name>string</ns:name>
> <ns:owner id="string" name="string"/>
> </ns:sgReference>
> </ns:st>
> </ns:owner>
> </ns:sts>
> </ns:data>
____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]