[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Get expected firstchild/siblings
I'm using the latest (1.2.3) apache XML parser. I have two dummy files (XML and XSD file) attached below. I'd need to be able to parse through test.xml and be able to somehow see that the element node "foo" can ONLY (and must) legally have the element "bar" as it's first child. I'd also like to be able to see that "bar" can have no child element, and either another "bar" sibling or no more siblings. Is this possible using any available parser? It doesn't seem hard, as parser's validator seem to already do such a thing. XML Spy also has helpers in the program that do such a task. However, I need to present this in a servlet via an XML parser. So, if anyone has ideas, please let me know. Thanks. -Pat test.xsd: <?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/1999/XMLSchema" elementFormDefault="qualified"> <xsd:element name="foo"> <xsd:annotation> <xsd:documentation>Comment describing your root element</xsd:documentation> </xsd:annotation> <xsd:complexType> <xsd:sequence> <xsd:element name="bar" type="xsd:string" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> test.xml: <?xml version="1.0" encoding="UTF-8"?> <foo xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:test.xsd"> <bar>foo</bar> </foo>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|