You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Paul Brown <pr...@fivesight.com> on 2002/03/04 22:46:28 UTC
Question about xsl:output, QName, and XSLTAttributeDef
Trying to get something working with Xalan-J2.1.0 (ducking flying fruit and
vegetables), I dug into SerializerToXML to figure out why my CDATA section
wasn't appearing where I asked for it. Then to ProcessorOutputElem, then to
XSLTAttributeDef, then to QName. The fix from Alexander Rudnev will work
for prefixed elements but not for non-prefixed
The QName constructor, when invoked with a String without a contained ':'
and a PrefixResolver, does not attempt to resolve the empty ("") namespace
URI. I can imagine that most of the time, this is a good thing, e.g., when
resolving the names of functions for XPath expressions, but in the
xsl:output context, the empty namespace should get resolved to whatever is
declared in xmlns="..." on the stylesheet root element.
The obvious fix is:
Vector processQNAMES(
StylesheetHandler handler, String uri, String name, String
rawName, String value)
throws org.xml.sax.SAXException
{
StringTokenizer tokenizer = new StringTokenizer(value, " \t\n\r\f");
int nQNames = tokenizer.countTokens();
Vector qnames = new Vector(nQNames);
String nullURI = handler.getNamespaceForPrefix("");
for (int i = 0; i < nQNames; i++)
{
String tok = tokenizer.nextToken();
if (tok.indexOf(':') == -1) {
qnames.addElement(new QName(nullURI,tok));
} else {
qnames.addElement(new QName(tokenizer.nextToken(),handler));
}
}
return qnames;
}
Anything wrong here?
-- Paul Brown