You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by David Green <da...@maketechnologies.com> on 2002/06/07 21:21:43 UTC
XTags feature request
A problem that I've encountered is related to xpaths and namespace prefixes:
if the parsed document has namespace prefixes, then our xpaths must
reference these -- however, if the expected document has changed prefixes
but same namespace uris (and is equivalent to the original), then my xpaths
break.
As far as I can see, XTags doesn't address this issue. If it does, could
someone direct me to information on this? Otherwise, how about this feature
request:
It would be great if we could specify a per-page prefix-to-namespace mapping
using XTags. This could be done by specifying a per-page DocumentFactory
instance, instead of what XTags currently does, which is using the global
instance org.dom4j.DocumentFactory#getInstance(). We could then call
org.dom4j.DocumentFactory#setNamespaceURIs(java.util.Map) on the per-page
factory.
Looking at the code, this change would be relatively easy to make. The
following would do it:
org.apache.taglibs.xtags.xpath.AbstractTag#getDocumentFactory() could be
modified as follows:
protected DocumentFactory getDocumentFactory() {
// get the page-scope factory if available.
DocumentFactory factory = (DocumentFactory)
pageContext.getAttribute(CTX_ATTRIBUTE_NAME_DOCUMENTFACTORY);
if (factory != null) return factory;
// if not available, return the default instance.
return DocumentFactory.getInstance();
}
A new tag could be created that would set the page-scope factory and
associated prefix-to-uri mapping as follows:
syntax example:
<xtags:defineUriPrefixes>
<xtags:namespaceDefinition uri="urn:foo.bar" prefix="foobar"/>
<xtags:namespaceDefinition uri="urn:example.com/some/uri" prefix="ecom"/>
</xtags:defineUriPrefixes>
I hope to hear comments on this. If necessary, I can contribute the code
required to make it work.
David
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>