xalan-c-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shath...@e-z.net
Subject Re: mapping a prefix to a namespace URI
Date Wed, 25 Sep 2013 19:16:54 GMT

When you mention "default" namespace, are you instead
trying to use a "no namespace" arena?

XML documents and fragments with no target namespace prefix
are allocated to the "no namespace" arena.

A namespace_name can be associated with more than one prefix.
The use of any of the prefixes can then validate to a
proper namespace.  Namespaces are bound to prefixes by the
XML Parser.  A Stylesheet can have its own namespace prefix
bindings that are emitted by the XML output method.

Nested namespace (xmlns:prefix='namespace_name') assignments
are allowed.  Parent namespaces that share a prefix that
has been redefined in the child element are not available
within the scope of the child element.

Any namespace (xmlns:prefix) mappings in the parent are
inherited by the child, but can be overwritten by the child

Xalan now has the ability to associate parsed XML documents
with a top-level parameter name.

Documents are parsed using the Xerces-C XML Parser library.

The way a resolver works is to map a URL or system file
pathname to a resource.  The resolver then pushes a reader
onto the XML Reader stack to start reading from the new
object (XML Document or fragment).

The XPath document() function returns a parsed nodeset object.
It uses the installed entity resolver that performs the
above mentioned operation by submitting a bytestream of
data to an XML parser so that a parsed nodeset object can
be returned by document().

Steven J. Hathaway

> Hi,
> I need to get some values from a number of xml sources that have default
> namespaces.  I've implemented the code from the sample SimplXPathAPI and
> got
> this to work if I removed the default namespaces but, if I leave them in,
> selectSingleNode returns NULL.  I was able to remove the namespaces for my
> test data (or add prefixes), but unfortunately I will not be able to do
> this
> with the real data.
> I've done an exhaustive search of the xalan-c forums and the internet in
> general for the past several days and I've come up with a few things but I
> don't think I'm heading in the right direction any longer.  I've
> implemented
> a PrefixResolver derivative (myPrefixResolver) and I'm passing an instance
> of that into the XPathEvaluator, so the XPath implementation can map the
> namespace prefix to the proper namespace URI.  The problem is that I'm
> having trouble mapping the prefix to the namespace.
> Optimally I would like to have a function in my PrefixResolver derivative
> that takes a prefix and a uri and adds it to my namespace.
> I've come up with the following (and many other variations) but it crashes
> when I try to set the node value.
> void
> myPrefixResolver::setPrefix(const XalanDOMString& prefix, const
> XalanDOMString& uri)
> {
> 	AttributeVectorType	myVector(XalanMemMgrs::getDefaultXercesMemMgr(), 1);
> 	myVector.front()->setNodeValue(uri);
> 	m_namespaces.insert(&prefix, myVector);
> }
> I've tried many things including tying to clone an existing XalanNode and
> creating my vector this way.  I haven't deviated much from the way
> XalanDocumentPrefixResolver derived from PrefixResolver.  I am a bit
> desperate at this point because I have a very tight schedule and I thought
> this part would be the easy part.
> Any help that can be proffered would be extremely appreciated!
> Thanks,
> Aaron
> --
> View this message in context:
> http://apache-xml-project.6118.n7.nabble.com/mapping-a-prefix-to-a-namespace-URI-tp40498.html
> Sent from the Xalan - C - Users mailing list archive at Nabble.com.

View raw message