xerces-c-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Glavassevich <mrgla...@ca.ibm.com>
Subject Re: Seeking help with extracting substitution group information from schema
Date Wed, 07 Dec 2011 03:11:45 GMT

Martin Uhrin <martin.uhrin@gmail.com> wrote on 11/15/2011 06:14:04 PM:

> first of all: thanks for the great library and any help that you can
> provide with my current predicament.
> I'm trying to extract the substitution group from my schema for a
> given element in my xml document.  I understand there might be a way
> to do this by implementing a custom PSVIHandler, however I've taken a
> slightly different route.  I instantiate a default GrammarPool and
> pass it to my DOMParser which I then use to load my schema.  I then
> parse my xml document and whenever I encounter an element that I need
> the substitution group for I do something along the following lines:
> GrammarPool->getXSModel()->getElementDeclaration
> (...)->getSubstitutionGroupAffiliation()->getName()
> So question 1) Is this a reasonable way to accomplish this or should I
> be using a different approach?

Computing an element's substitution group is more complex than that. An
element can block substitutions. You would need to check that too.

For convenience, we added the getSubstitutionGroup() method [1] to the Java
version of XSModel. Seems like that was never added to Xerces-C++.

> Question 2)
> Currently, the way I match the element to the element declaration is
> along the following lines:
> XSModel->getElementDeclaration(element->getLocalName(),
> element->getNamespaceURI())
> this feels like it may not work in all cases.  How does Xerces match
> each element to an element declaration when it is doing validation?  I
> had a good look through the source but I couldn't see how this is
> done.

Also more complex than that. It uses a state machine [2].

> Many thanks,
> -Martin



Michael Glavassevich
XML Technologies and WAS Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message