Methods Summary |
---|
public int | doEndTag()
try {
// set up our DocumentBuilder
if (dbf == null) {
dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
dbf.setValidating(false);
}
db = dbf.newDocumentBuilder();
// if we've gotten a filter, set up a transformer to support it
if (filter != null) {
if (tf == null)
tf = TransformerFactory.newInstance();
if (!tf.getFeature(SAXTransformerFactory.FEATURE))
throw new JspTagException(
Resources.getMessage("PARSE_NO_SAXTRANSFORMER"));
SAXTransformerFactory stf = (SAXTransformerFactory) tf;
th = stf.newTransformerHandler();
}
// produce a Document by parsing whatever the attributes tell us to use
Document d;
Object xmlText = this.xml;
if (xmlText == null) {
// if the attribute was specified, use the body as 'xml'
if (bodyContent != null && bodyContent.getString() != null)
xmlText = bodyContent.getString().trim();
else
xmlText = "";
}
if (xmlText instanceof String)
d = parseStringWithFilter((String) xmlText, filter);
else if (xmlText instanceof Reader)
d = parseReaderWithFilter((Reader) xmlText, filter);
else
throw new JspTagException(
Resources.getMessage("PARSE_INVALID_SOURCE"));
// we've got a Document object; store it out as appropriate
// (let any exclusivity or other constraints be enforced by TEI/TLV)
if (var != null)
pageContext.setAttribute(var, d, scope);
if (varDom != null)
pageContext.setAttribute(varDom, d, scopeDom);
return EVAL_PAGE;
} catch (SAXException ex) {
throw new JspException(ex);
} catch (IOException ex) {
throw new JspException(ex);
} catch (ParserConfigurationException ex) {
throw new JspException(ex);
} catch (TransformerConfigurationException ex) {
throw new JspException(ex);
}
|
private void | init()
var = varDom = null;
xml = null;
systemId = null;
filter = null;
dbf = null;
db = null;
tf = null;
th = null;
scope = PageContext.PAGE_SCOPE;
scopeDom = PageContext.PAGE_SCOPE;
|
private org.w3c.dom.Document | parseInputSource(org.xml.sax.InputSource s)Parses the given InputSource into a Document.
db.setEntityResolver(new JstlEntityResolver(pageContext));
// normalize URIs so they can be processed consistently by resolver
if (systemId == null)
s.setSystemId("jstl:");
else if (ImportSupport.isAbsoluteUrl(systemId))
s.setSystemId(systemId);
else
s.setSystemId("jstl:" + systemId);
return db.parse(s);
|
private org.w3c.dom.Document | parseInputSourceWithFilter(org.xml.sax.InputSource s, org.xml.sax.XMLFilter f)Parses the given InputSource after, applying the given XMLFilter.
if (f != null) {
// prepare an output Document
Document o = db.newDocument();
// use TrAX to adapt SAX events to a Document object
th.setResult(new DOMResult(o));
XMLReader xr = XMLReaderFactory.createXMLReader();
xr.setEntityResolver(new JstlEntityResolver(pageContext));
// (note that we overwrite the filter's parent. this seems
// to be expected usage. we could cache and reset the old
// parent, but you can't setParent(null), so this wouldn't
// be perfect.)
f.setParent(xr);
f.setContentHandler(th);
f.parse(s);
return o;
} else
return parseInputSource(s);
|
private org.w3c.dom.Document | parseReader(java.io.Reader r)Parses the given Reader into a Document.
return parseInputSource(new InputSource(r));
|
private org.w3c.dom.Document | parseReaderWithFilter(java.io.Reader r, org.xml.sax.XMLFilter f)Parses the given Reader after applying the given XMLFilter.
return parseInputSourceWithFilter(new InputSource(r), f);
|
private org.w3c.dom.Document | parseString(java.lang.String s)Parses the given String into a Document.
StringReader r = new StringReader(s);
return parseReader(r);
|
private org.w3c.dom.Document | parseStringWithFilter(java.lang.String s, org.xml.sax.XMLFilter f)Parses the given String after applying the given XMLFilter.
StringReader r = new StringReader(s);
return parseReaderWithFilter(r, f);
|
private org.w3c.dom.Document | parseURL(java.lang.String url)Parses the URL (passed as a String) into a Document.
return parseInputSource(new InputSource(url));
|
private org.w3c.dom.Document | parseURLWithFilter(java.lang.String url, org.xml.sax.XMLFilter f)Parses the given Reader after applying the given XMLFilter.
return parseInputSourceWithFilter(new InputSource(url), f);
|
public void | release()
init();
|
public void | setScope(java.lang.String scope)
this.scope = Util.getScope(scope);
|
public void | setScopeDom(java.lang.String scopeDom)
this.scopeDom = Util.getScope(scopeDom);
|
public void | setVar(java.lang.String var)
this.var = var;
|
public void | setVarDom(java.lang.String varDom)
this.varDom = varDom;
|