Jim Whitehead
Usenet Archive
- Joined
- Aug 15, 2003
- Messages
- 4
- Reaction score
- 0
If I have a well-formed XML document, can I somehow tell a validating parser to ignore selected tags? I want these tags to be ignored for validation purposes, bit I still want to validate the contents of these tags based on the rules applicable to their parent tags.
For example, if my schema looks something like this:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="Parent"> <xs:complexType> <xs:sequence> <xs:element name="Child"> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="Child"/> <xs:element name="TransparentTag"/> <xs:element name="SomeOtherTag"/> </xs:schema>
I would like this to be valid:
<Parent>
<TransparentTag><Child>Jim</Child></TransparentTag>
</Parent>
But not this:
<Parent>
<SomeOtherTag><Child>Jim</Child></SomeOtherTag>
</Parent>
or this:
<Parent>
<TransparentTag><Sibling>Lucy</Sibling></TransparentTag> </Parent>
We have enough of these types of tags, like TransparentTag, that spelling out all the possible combinations in my schema would be impractical, and would make our schema extremely large. We could possibly use a really loose schema. For example, we could allow a "Parent" tag to have either a "Child" tag or a "TransparentTag", or both types of tag, and then we could allow a "TransparentTag" to hold any other tag. But we would prefer a stricter schema, if possible.
Using <any> doesn't seem to help, because this allows any tag from, say, a given namespace, but then it doesn't validate the contents of this tag based on rules applying to the parent tag.
Any suggestion or ideas would be much appreciated. Also, I apologize if my previous posting on this topic was not clear.
Thank you.
Jim Whitehead
For example, if my schema looks something like this:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="Parent"> <xs:complexType> <xs:sequence> <xs:element name="Child"> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="Child"/> <xs:element name="TransparentTag"/> <xs:element name="SomeOtherTag"/> </xs:schema>
I would like this to be valid:
<Parent>
<TransparentTag><Child>Jim</Child></TransparentTag>
</Parent>
But not this:
<Parent>
<SomeOtherTag><Child>Jim</Child></SomeOtherTag>
</Parent>
or this:
<Parent>
<TransparentTag><Sibling>Lucy</Sibling></TransparentTag> </Parent>
We have enough of these types of tags, like TransparentTag, that spelling out all the possible combinations in my schema would be impractical, and would make our schema extremely large. We could possibly use a really loose schema. For example, we could allow a "Parent" tag to have either a "Child" tag or a "TransparentTag", or both types of tag, and then we could allow a "TransparentTag" to hold any other tag. But we would prefer a stricter schema, if possible.
Using <any> doesn't seem to help, because this allows any tag from, say, a given namespace, but then it doesn't validate the contents of this tag based on rules applying to the parent tag.
Any suggestion or ideas would be much appreciated. Also, I apologize if my previous posting on this topic was not clear.
Thank you.
Jim Whitehead