Jump to content

rsfm

Members
  • Content Count

    2
  • Joined

  • Last visited

Community Reputation

0 Neutral

About rsfm

  • Rank
    Newbie
  1. sorry little correction to the code, though it still doesn't work:child elements' ids have to reference to the registered child elements' ids.testing2.xsd: <?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="testing2" xmlns="testing2"> <xs:element name="child"> <xs:complexType> <xs:attribute name="id" type="xs:string" use="required" /> </xs:complexType> </xs:element> <xs:element name="registeredChild"> <xs:complexType> <xs:attribute name="id" type="xs:string" use="required" /> </xs:complexType> </xs:element> <xs:element name="parent"> <xs:complexType> <xs:sequence> <xs:element ref="registeredChild" maxOccurs="unbounded" /> <xs:element ref="child" maxOccurs="unbounded" /> </xs:sequence> </xs:complexType> <xs:key name="childKey"> <xs:selector xpath="registeredChild" /> <xs:field xpath="@id" /> </xs:key> <xs:keyref name="childKeyRef" refer="childKey"> <xs:selector xpath="child" /> <xs:field xpath="@id" /> </xs:keyref> </xs:element></xs:schema> testing2.xml: <?xml version="1.0" encoding="UTF-8"?><parent xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="testing2" xsi:schemaLocation="testing2 testing2.xsd"> <registeredChild id="c123" /> <registeredChild id="c235" /> <child id="c123" /> <child id="c234" /></parent> thanks
  2. hi, I tried using schema keys with noNamespaceSchemalocation, it worked.However, when I try to use schema keys with namespaces, it fails to detect keys not matched. The observation is as if there is no schema key declared in the schema. Below are the xml file and the schema I tried on. Please point out where I am wrong on it. Thanks ahead.testing2.xml: <?xml version="1.0" encoding="UTF-8"?><parent xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="testing2" xsi:schemaLocation="testing2 testing2.xsd"> <registeredChild id="c123" /> <registeredChild id="c235" /> <child id="c123" /> <child id="c234" /></parent> testing2.xsd <?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="testing2" xmlns="testing2"> <xs:element name="child"> <xs:complexType> <xs:attribute name="id" type="xs:string" use="required" /> </xs:complexType> </xs:element> <xs:element name="registeredChild"> <xs:complexType> <xs:attribute name="id" type="xs:string" use="required" /> </xs:complexType> </xs:element> <xs:element name="parent"> <xs:complexType> <xs:sequence> <xs:sequence> <xs:element ref="registeredChild" maxOccurs="unbounded" /> </xs:sequence> <xs:element ref="child" maxOccurs="unbounded" /> </xs:sequence> </xs:complexType> <xs:key name="childKey"> <xs:selector xpath="registeredChild" /> <xs:field xpath="id" /> </xs:key> <xs:keyref name="childKeyRef" refer="childKey"> <xs:selector xpath="child" /> <xs:field xpath="@id" /> </xs:keyref> </xs:element></xs:schema>
×
×
  • Create New...