[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Get expected firstchild/siblings

  • From: Patrick Lightbody <plightbo@c...>
  • To: xml-dev@l...
  • Date: Sun, 21 Jan 2001 15:33:36 -0800

firstchild sibling
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!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.