Hello everybody. I am newbie so it is posible this will be a nosense question. Sorry.
I want to define a tree on XML file with references to his nodes and xscheme validate. I am using SCMPrint xerces 2.7 C++ example to *validate* xchema file and SAXPrint example to validate xml file. This is the xml file example. <!-- ============= nodes.xml ================ --> <?xml version="1.0" encoding="iso-8859-1" ?> <MAIN xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation='nodes.xsd'> <TREE> <NODE id="1"> <NODE id="1_1"> <NODE id="1_1_1"/> <NODE id="1_1_2"/> </NODE> <NODE id="1_2"> <NODE id="1_2_1"/> <NODE id="1_2_2"/> </NODE> </NODE> <NODE id="2"> <NODE id="2_1"> <NODE id="2_1_1"/> <NODE id="2_1_2"/> </NODE> <NODE id="2_2"> <NODE id="2_2_1"/> <NODE id="2_2_2"/> </NODE> </NODE> <!-- This is a error example. Duplicate definition --> <NODE id="2_1_2"/> </TREE> <REFERENCES> <REFERENCE ref="1"/> <REFERENCE ref="1_1"/> <REFERENCE ref="1_2_1"/> <!-- this is a error example. No defined reference. --> <REFERENCE ref="3"/> </REFERENCES> </MAIN> <!-- ============== EOF =================== --> I think this the correct xscheme file. <!-- ============= nodes.xsd ================ --> <?xml version="1.0" encoding="ISO-8859-1" ?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <!-- =================================================== --> <xsd:complexType name="TypeNode"> <xsd:sequence> <xsd:element name="NODE" type="TypeNode" minOccurs="0" maxOccurs='unbounded'/> </xsd:sequence> <xsd:attribute name="id" type="xsd:string" use="required"/> </xsd:complexType> <!-- =================================================== --> <xsd:complexType name="TypeRefNode"> <xsd:attribute name="ref" type="xsd:string" use="required"/> </xsd:complexType> <!-- =================================================== --> <xsd:element name="MAIN"> <xsd:complexType> <xsd:sequence> <xsd:element name="TREE"> <xsd:complexType> <xsd:sequence> <xsd:element name="NODE" type="TypeNode" minOccurs="0" maxOccurs='unbounded'/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="REFERENCES" > <xsd:complexType> <xsd:sequence> <xsd:element name="REFERENCE" type="TypeRefNode" minOccurs="0" maxOccurs='unbounded'/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType> <xsd:key name="IdNodes"> <xsd:selector xpath="TREE/descendant::*"/> <xsd:field xpath="@id"/> </xsd:key> <xsd:keyref name="IdRefNodes" refer="IdNodes"> <xsd:selector xpath="REFERENCES/REFERENCE"/> <xsd:field xpath="@ref"/> </xsd:keyref> </xsd:element> </xsd:schema> <!-- ============== EOF =================== --> If I execute : ================================================== [EMAIL PROTECTED]:~/pro$ SCMPrint nodes.xsd Error at file /home/jlz/pro/nodes.xsd, line 50, char 49 Message: XPath token not supported Error at file /home/jlz/pro/nodes.xsd, line 54, char 51 Message: Key reference declaration 'IdRefNodes' refers to unknown key with name 'IdNodes'. Did not parse a schema document cleanly so not printing Schema for Schema XSModel information ================================================== Xerces don't understand "descendant::*" XPath token. Why? Is it correct?? How I can do this in other manner??? If I change <xsd:key name="IdNodes"> <xsd:selector xpath="TREE/descendant::*"/> <xsd:field xpath="@id"/> </xsd:key> by <xsd:key name="IdNodes"> <xsd:selector xpath="TREE/*"/> <xsd:field xpath="@id"/> </xsd:key> only the first children are identified. It's correct but it's not the target. Thank you very munch in avance. -- José Luis Zabalza jlz.3008 at gmail.com Linux Counter 172551
