You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by ma...@quick.co.jp on 2004/03/18 13:51:31 UTC
RE: using
I encountered a problem pretty much similar to one of the previous posts :
http://www.mail-archive.com/taglibs-user@jakarta.apache.org/msg04896.html
I read the source code of the Jakarta Standard Template Library 1.0.5 and
got a doubt to it.
In the "org/apache/taglibs/standard/tag/common/xml/TransformSupport.java",
we now have the following code fragment.
----------------------------------------------------------------
/**
* Retrieves a Source from the given Object, whether it be a String,
* Reader, Node, or other supported types (even a Source already).
* If 'url' is true, then we must be passed a String and will interpret
* it as a URL. A null input always results in a null output.
*/
private Source getSource(Object o, String systemId)
throws SAXException, ParserConfigurationException, IOException {
if (o == null)
return null;
else if (o instanceof Source) {
return (Source) o;
} else if (o instanceof String) {
// if we've got a string, chain to Reader below
return getSource(new StringReader((String) o), systemId);
} else if (o instanceof Reader) {
// explicitly go through SAX to maintain control
// over how relative external entities resolve
XMLReader xr = XMLReaderFactory.createXMLReader();
xr.setEntityResolver(
new ParseSupport.JstlEntityResolver(pageContext));
InputSource s = new InputSource((Reader) o);
s.setSystemId(wrapSystemId(systemId));
Source result = new SAXSource(xr, s);
result.setSystemId(wrapSystemId(systemId));
return result;
} else if (o instanceof Node) {
return new DOMSource((Node) o);
} else if (o instanceof List) {
// support 1-item List because our XPath processor outputs them
List l = (List) o;
if (l.size() == 1) {
return getSource(l.get(0), systemId); // unwrap List
} else {
throw new IllegalArgumentException(
Resources.getMessage("TRANSFORM_SOURCE_INVALID_LIST"));
}
} else {
throw new IllegalArgumentException(
Resources.getMessage("TRANSFORM_SOURCE_UNRECOGNIZED")
+ o.getClass());
}
}
---------------------------------------------------------------
I suppose the portion for DOM should be something like:
---------------------------------------------------------------
} else if (o instanceof Node) {
DOMSource ds = new DOMSource((Node) o);
ds.setSystemId(systemId);
return ds;
}
---------------------------------------------------------------
[Point]: set the SystemID attribute for the DOMSource object to be
returned,
as the current code is doing for the StreamSource object.
I have just noticed this, will test my thought tommorow.
---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org