Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSD doesn't validate XPath 1

Status
Not open for further replies.

EwS

Programmer
Dec 30, 2002
398
US
I'm fairly new to xsd. I'm validating xml against xsd using XmlReaderSettings. It looks like my xsd does not verify the element path: My schema definition allows for both OrderProperties and OrderPartners elements, however Partner can be specified only under OrderPartners. In other words, the correct path is OrderPartners/Partner, not OrderProperties/Partner. My xml contains OrderProperties/Partner ONLY and my xml validation code does not give me an error (I'm sure the code is working since it's giving me other errors such as invalid value for an attribute or missing element). I'm trying to figure out if there's something wrong with my validation code or the xsd. Before posting any code, I want to confirm what seems to me to be the case:
1. It is possible to make xsd to impose specific XPath.
2. If xsd requires certain XPath, I have no control over whether the XPath is validated or not.

Thank you for any comments.
 
The xsd I'm using is rather complex, I didn't write it, it's third party and I prefer not to dig deep into it. I just need to get a general idea of how xsd works, specifically if it's possible for xsd to "prevent" xml from having an element in the wrong place. As far as I know you can specify which child elements are allowed on a certain
element (this is exactly what I mean when I say, "xsd to impose specific XPath), but then, why don't I get any errors if I specify a child element that is invalid? Again:
OrderPartners/Partner is correct
OrderProperties/Partner is not
 
>I just need to get a general idea of how xsd works, specifically if it's possible for xsd to "prevent" xml from having an element in the wrong place. As far as I know you can specify which child elements are allowed on a certain element (this is exactly what I mean when I say, "xsd to impose specific XPath)...
For WXSL, it imposes parent-child element relationship as its scope of business via element type. Different element type of the parent defines its own child elements as part of its definition. So, in this sense, the general idea is yes, it is possible to impose that condition.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top