Stanimir Stamenkov <s7a...@netscape.net> wrote on 10/24/2010 06:51:13 AM:

> > Your example is still dealing with the interpretation of a prefix
> > in an existing document, and I don't have an existing document.
> > I am in control of which namespaces and which prefixes would be
> > used.
>
> As Michael has already pointed out the schema is the existing
> document which you would like to extract the prefixes from.  I've
> previously needed such functionality and my approach was to iterate
> over the 'namespaceItems' of the built 'XSModel', then parse (using
> SAX) each 'XSNamespaceItem.documentLocations' only until reaching
> the root element (throwing something like StopParseException subtype
> of SAXParseException from withing 'startElement' callback) from
> which I extract whatever namespace prefixes found on it.  The
> structure collecting the prefix-namespace bindings takes care to not
> register two or more namespaces to the same prefix.  It also
> automatically generated prefixes for namespaces (appart from the
> registered default namespace which could be the no-namespace) which
> don't have prefix assigned later, in my case.

Need to take special care with the default namespace since it never applies
to attribute names. If you use it you may need to generate an additional
prefix binding for attributes with that namespace. May also need to be
prepared to undeclare the default namespace in the middle of the document
if you're using it around content which may have elements or QName values
with no namespace.

> --
> Stanimir
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscr...@xerces.apache.org
> For additional commands, e-mail: j-users-h...@xerces.apache.org

Thanks.

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrgla...@ca.ibm.com
E-mail: mrgla...@apache.org

Reply via email to