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 sh...@apache.org on 2002/04/17 14:42:39 UTC
cvs commit: jakarta-taglibs/standard/src/org/apache/taglibs/standard/tei XmlTransformTEI.java
shawn 02/04/17 05:42:39
Modified: standard/examples/web/xml Parse.jsp Transform.jsp
standard/src/org/apache/taglibs/standard/tag/common/xml
ParseSupport.java TransformSupport.java
standard/src/org/apache/taglibs/standard/tag/el/xml
ParseTag.java TransformTag.java
standard/src/org/apache/taglibs/standard/tag/rt/xml
ParseTag.java TransformTag.java
standard/src/org/apache/taglibs/standard/tei
XmlTransformTEI.java
Added: standard/examples/web/xml ParseWithEntities.jsp
TransformWithInclusion.jsp included.xml
includedStylesheet.xsl
Removed: standard/src/org/apache/taglibs/standard/lang/dummy
DummyEvaluator.java
standard/src/org/apache/taglibs/standard/tag/common/xml
TransformerSupport.java
Log:
Updates to XML library for PFD spec
- primarily related to system identifiers and relative entity references
Revision Changes Path
1.5 +2 -8 jakarta-taglibs/standard/examples/web/xml/Parse.jsp
Index: Parse.jsp
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/examples/web/xml/Parse.jsp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Parse.jsp 17 Apr 2002 02:53:38 -0000 1.4
+++ Parse.jsp 17 Apr 2002 12:42:39 -0000 1.5
@@ -3,7 +3,7 @@
<html>
<head>
- <title>JSTL: XML Support -- Parse from Objects and URLs</title>
+ <title>JSTL: XML Support -- Parse</title>
</head>
<body bgcolor="#FFFFFF">
<h3>Parse from Objects and URLs</h3>
@@ -21,16 +21,10 @@
</a>
</c:set>
-<x:parse var="a" xmlText="${xmlText}" />
+<x:parse var="a" xml="${xmlText}" />
<x:out select="$a//c"/>
<x:out select="$a/a/d"/>
-
-<hr />
-
-<x:parse var="a" xmlUrl="http://www.cnn.com/cnn.rss" />
-
-Title of news feed: "<x:out select="$a//title"/>"
</body>
</html>
1.6 +5 -21 jakarta-taglibs/standard/examples/web/xml/Transform.jsp
Index: Transform.jsp
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/examples/web/xml/Transform.jsp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Transform.jsp 17 Apr 2002 02:53:38 -0000 1.5
+++ Transform.jsp 17 Apr 2002 12:42:39 -0000 1.6
@@ -25,43 +25,27 @@
</c:set>
Prints "header" as a header:<br />
-<x:transform xmlText="${xml}" xsltText="${xsl}"/>
+<x:transform xml="${xml}" xslt="${xsl}"/>
<hr />
Prints "header" in normal size:<br />
-<x:transform xmlText="${xml}" xsltText="${xsl}" var="doc"/>
+<x:transform xml="${xml}" xslt="${xsl}" var="doc"/>
<x:out select="$doc//h1"/>
<hr size="5" />
-<h3>Transformations using URLs</h3>
-
-<c:set var="xslt">
- <?xml version="1.0"?>
- <xsl:stylesheet
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-
- <xsl:template match="text()">
- <p><xsl:value-of select="."/></p>
- </xsl:template>
-
- </xsl:stylesheet>
-</c:set>
-
-<x:transform xsltText="${xslt}" xmlUrl="http://www.cnn.com/cnn.rss" />
-
<hr />
<h3>Transformations using output from XPath expressions</h3>
-<x:parse var="xml" xmlText="${xml}" />
+<x:parse var="xml" xml="${xml}" />
<x:set var="miniDoc" select="$xml//b" />
-<x:transform xsltText="${xslt}" xmlText="${miniDoc}" />
+<x:transform xslt="${xsl}" xml="${miniDoc}" />
<hr />
<h3>Inline transformations</h3>
-<x:transform xsltText="${xslt}">
+<x:transform xslt="${xsl}">
<a>
<b>
<c>Paragraph one!</c>
1.1 jakarta-taglibs/standard/examples/web/xml/ParseWithEntities.jsp
Index: ParseWithEntities.jsp
===================================================================
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="x" uri="http://java.sun.com/jstl/xml" %>
<html>
<head>
<title>JSTL: XML Support -- Parse</title>
</head>
<body bgcolor="#FFFFFF">
<h3>Parse from Objects and URLs</h3>
<c:set var="xmlText">
<?xml version="1.0"?>
<!DOCTYPE project [
<!ENTITY included SYSTEM "included.xml">
]>
<root>
&included;
</root>
</c:set>
<x:parse var="a" xml="${xmlText}" systemId="foo.xml"/>
<x:out select="$a//*"/>
</body>
</html>
1.1 jakarta-taglibs/standard/examples/web/xml/TransformWithInclusion.jsp
Index: TransformWithInclusion.jsp
===================================================================
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="x" uri="http://java.sun.com/jstl/xml" %>
<html>
<head>
<title>JSTL: XML Support -- Transform</title>
</head>
<body bgcolor="#FFFFFF">
<h3>Parse / Expr</h3>
<c:set var="xml">
<?xml version="1.0"?>
<!DOCTYPE project [
<!ENTITY included SYSTEM "included.xml">
]>
<root>
&included;
</root>
</c:set>
<c:set var="xsl">
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="/xml/includedStylesheet.xsl" />
</xsl:stylesheet>
</c:set>
<x:transform xml="${xml}" xmlSystemId="foo.xml" xslt="${xsl}"/>
1.1 jakarta-taglibs/standard/examples/web/xml/included.xml
Index: included.xml
===================================================================
<a>
<b>YES!</b>
</a>
1.1 jakarta-taglibs/standard/examples/web/xml/includedStylesheet.xsl
Index: includedStylesheet.xsl
===================================================================
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="text()">
<h1><xsl:value-of select="."/></h1>
</xsl:template>
</xsl:stylesheet>
1.4 +68 -22 jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/xml/ParseSupport.java
Index: ParseSupport.java
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/xml/ParseSupport.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ParseSupport.java 4 Feb 2002 02:39:51 -0000 1.3
+++ ParseSupport.java 17 Apr 2002 12:42:39 -0000 1.4
@@ -56,6 +56,8 @@
package org.apache.taglibs.standard.tag.common.xml;
import java.io.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import javax.xml.parsers.*;
@@ -66,6 +68,7 @@
import org.xml.sax.*;
import org.xml.sax.helpers.XMLFilterImpl;
import org.xml.sax.helpers.XMLReaderFactory;
+import org.apache.taglibs.standard.tag.common.core.ImportSupport;
import org.apache.taglibs.standard.tag.common.core.Util;
import org.apache.taglibs.standard.resources.Resources;
@@ -79,8 +82,8 @@
//*********************************************************************
// Protected state
- protected Object xmlText; // 'xmlText' attribute
- protected String xmlUrl; // 'xmlUrl' attribute
+ protected Object xml; // 'xml' attribute
+ protected String systemId; // 'systemId' attribute
protected XMLFilter filter; // 'filter' attribute
//*********************************************************************
@@ -108,8 +111,8 @@
private void init() {
var = varDom = null;
- xmlText = null;
- xmlUrl = null;
+ xml = null;
+ systemId = null;
filter = null;
dbf = null;
db = null;
@@ -131,6 +134,7 @@
if (dbf == null) {
dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
+ dbf.setValidating(false);
}
db = dbf.newDocumentBuilder();
@@ -147,25 +151,21 @@
// produce a Document by parsing whatever the attributes tell us to use
Document d;
- Object xmlText = this.xmlText;
- if (xmlText == null && xmlUrl == null) {
- // if neither attribute was specified, use the body as 'xmlText'
+ 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 (xmlUrl != null)
- d = parseURLWithFilter(xmlUrl, filter);
- else {
- 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"));
- }
+ 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)
@@ -176,13 +176,13 @@
return EVAL_PAGE;
} catch (SAXException ex) {
- throw new JspTagException(ex.toString());
+ throw new JspException(ex);
} catch (IOException ex) {
- throw new JspTagException(ex.toString());
+ throw new JspException(ex);
} catch (ParserConfigurationException ex) {
- throw new JspTagException(ex.toString());
+ throw new JspException(ex);
} catch (TransformerConfigurationException ex) {
- throw new JspTagException(ex.toString());
+ throw new JspException(ex);
}
}
@@ -205,6 +205,7 @@
// 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
@@ -239,6 +240,9 @@
/** Parses the given InputSource into a Document. */
private Document parseInputSource(InputSource s)
throws SAXException, IOException {
+ db.setEntityResolver(new JstlEntityResolver(pageContext));
+ if (systemId != null)
+ s.setSystemId(systemId);
return db.parse(s);
}
@@ -258,6 +262,48 @@
return parseInputSource(new InputSource(url));
}
+ //*********************************************************************
+ // JSTL-specific EntityResolver class
+
+ /** Lets us resolve relative external entities. */
+ public static class JstlEntityResolver implements EntityResolver {
+ private final PageContext ctx;
+ public JstlEntityResolver(PageContext ctx) {
+ this.ctx = ctx;
+ }
+ public InputSource resolveEntity(String publicId, String systemId)
+ throws FileNotFoundException {
+ // pass if we don't have a systemId
+ if (systemId == null)
+ return null;
+
+ // strip leading "file:" off URL if applicable
+ if (systemId.startsWith("file:"))
+ systemId = systemId.substring(5);
+
+ // we're only concerned with relative URLs
+ if (ImportSupport.isAbsoluteUrl(systemId))
+ return null;
+
+ // for relative URLs, load and wrap the resource.
+ // don't bother checking for 'null' since we specifically want
+ // the parser to fail if the resource doesn't exist
+ InputStream s;
+ if (systemId.startsWith("/")) {
+ s = ctx.getServletContext().getResourceAsStream(systemId);
+ if (s == null)
+ throw new FileNotFoundException(systemId);
+ } else {
+ String pagePath =
+ ((HttpServletRequest) ctx.getRequest()).getServletPath();
+ String basePath =
+ pagePath.substring(0, pagePath.lastIndexOf("/"));
+ s = ctx.getServletContext().getResourceAsStream(
+ basePath + "/" + systemId);
+ }
+ return new InputSource(s);
+ }
+ }
//*********************************************************************
// Tag attributes
1.7 +136 -71 jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/xml/TransformSupport.java
Index: TransformSupport.java
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/xml/TransformSupport.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- TransformSupport.java 4 Feb 2002 02:39:51 -0000 1.6
+++ TransformSupport.java 17 Apr 2002 12:42:39 -0000 1.7
@@ -57,13 +57,20 @@
import java.io.*;
import java.util.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import javax.xml.parsers.*;
import javax.xml.transform.*;
+import javax.xml.transform.sax.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.stream.*;
+import org.xml.sax.*;
+import org.xml.sax.helpers.XMLFilterImpl;
+import org.xml.sax.helpers.XMLReaderFactory;
import org.w3c.dom.*;
+import org.apache.taglibs.standard.tag.common.core.ImportSupport;
import org.apache.taglibs.standard.tag.common.core.Util;
import org.apache.taglibs.standard.resources.Resources;
@@ -78,11 +85,11 @@
//*********************************************************************
// Protected state
- protected Object xmlText; // 'xmlText' attribute
- protected String xmlUrl; // 'xmlUrl' attribute
- protected Object xsltText; // 'xsltText' attribute
- protected String xsltUrl; // 'xsltUrl' attribute
- protected Result result; // 'result' attribute
+ protected Object xml; // attribute
+ protected String xmlSystemId; // attribute
+ protected Object xslt; // attribute
+ protected String xsltSystemId; // attribute
+ protected Result result; // attribute
//*********************************************************************
// Private state
@@ -92,6 +99,7 @@
private Transformer t; // actual Transformer
private TransformerFactory tf; // reusable factory
private DocumentBuilder db; // reusable factory
+ private DocumentBuilderFactory dbf; // reusable factory
//*********************************************************************
@@ -103,8 +111,8 @@
}
private void init() {
- xmlText = xsltText = null;
- xmlUrl = xsltUrl = null;
+ xml = xslt = null;
+ xmlSystemId = xsltSystemId = null;
var = null;
result = null;
tf = null;
@@ -133,26 +141,31 @@
//************************************
// Produce transformer
- // we can assume exactly one of 'xsltText' or 'xsltUrl' is specified
Source s;
- if (xsltUrl != null)
- s = getSource(xsltUrl, true);
- else if (xsltText != null)
- s = getSource(xsltText, false);
- else
+ if (xslt != null) {
+ s = getSource(xslt, xsltSystemId);
+ } else {
throw new JspTagException(
Resources.getMessage("TRANSFORM_NO_TRANSFORMER"));
+ }
+ tf.setURIResolver(new JstlUriResolver(pageContext));
t = tf.newTransformer(s);
return EVAL_BODY_BUFFERED;
+ } catch (SAXException ex) {
+ throw new JspException(ex);
+ } catch (ParserConfigurationException ex) {
+ throw new JspException(ex);
+ } catch (IOException ex) {
+ throw new JspException(ex);
} catch (TransformerConfigurationException ex) {
- throw new JspTagException(ex.toString());
+ throw new JspException(ex);
}
}
- // parse 'xmlText', 'xmlUrl', or body, transform via our Transformer,
- // and store as 'var' or 'result'
+ // parse 'xml' or body, transform via our Transformer,
+ // and store as 'var' or through 'result'
public int doEndTag() throws JspException {
try {
@@ -160,16 +173,18 @@
// Initialize
// set up our DocumentBuilderFactory if necessary
- if (db == null)
- db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ if (dbf == null) {
+ dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+ dbf.setValidating(false);
+ } if (db == null)
+ db = dbf.newDocumentBuilder();
//************************************
// Determine source XML
// if we haven't gotten a source, use the body (which may be empty)
- Object xml = xmlUrl;
- if (xml == null)
- xml = xmlText;
+ Object xml = this.xml;
if (xml == null) // still equal
if (bodyContent != null && bodyContent.getString() != null)
xml = bodyContent.getString().trim();
@@ -177,7 +192,7 @@
xml = "";
// let the Source be with you
- Source source = getSource(xml, xmlUrl != null);
+ Source source = getSource(xml, xmlSystemId);
//************************************
// Conduct the transformation
@@ -193,31 +208,20 @@
t.transform(source, doc);
pageContext.setAttribute(var, d, scope);
} else {
- ////
- // Replaced in favor of the optimized method below, suggested
- // by Bob Lee.
- // /*
- // * We're going to output the text directly. I'd love to
- // * construct a StreamResult directly from pageContext.getOut(),
- // * but I can't trust the transformer not to flush our writer.
- // */
- // StringWriter bufferedResult = new StringWriter();
- // Result page = new StreamResult(bufferedResult);
- // t.transform(xml, page);
- // pageContext.getOut().print(bufferedResult);
-
Result page =
new StreamResult(new SafeWriter(pageContext.getOut()));
t.transform(source, page);
}
return EVAL_PAGE;
- // } catch (IOException ex) {
- // throw new JspTagException(ex.toString());
+ } catch (SAXException ex) {
+ throw new JspException(ex);
} catch (ParserConfigurationException ex) {
- throw new JspTagException(ex.toString());
+ throw new JspException(ex);
+ } catch (IOException ex) {
+ throw new JspException(ex);
} catch (TransformerException ex) {
- throw new JspTagException(ex.toString());
+ throw new JspException(ex);
}
}
@@ -237,7 +241,7 @@
//*********************************************************************
- // Utility methods for package
+ // Utility methods
/**
* Retrieves a Source from the given Object, whether it be a String,
@@ -245,37 +249,58 @@
* 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.
*/
- static Source getSource(Object o, boolean url) {
- if (o == null) {
+ private Source getSource(Object o, String systemId)
+ throws SAXException, ParserConfigurationException, IOException {
+ if (o == null)
return null;
- }
-
- if (url) {
- return new StreamSource((String) o);
- } else {
- if (o instanceof Source) {
- return (Source) o;
- } else if (o instanceof String) {
- Reader s = new StringReader((String) o);
- return new StreamSource(s);
- } else if (o instanceof Reader) {
- return new StreamSource((Reader) o);
- } 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), false); // unwrap List
- } else {
- throw new IllegalArgumentException(
- Resources.getMessage("TRANSFORM_SOURCE_INVALID_LIST"));
- }
- } else {
- throw new IllegalArgumentException(
- Resources.getMessage("TRANSFORM_SOURCE_UNRECOGNIZED")
- + o.getClass());
- }
+ 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) {
+ // Without a systemId, or with an absolute one, we can
+ // read the input through SAX. If our systemId relative,
+ // however, JAXP seems to effectively require us to go through DOM.
+ // (TrAX resolves our relative URLs to full paths before
+ // passing them to our resolver.) This is silly, but what can
+ // you do? If this is a bug and not a feature of the TrAX
+ // implementation, we can remove the DOM logic below, later.
+ if (systemId == null || ImportSupport.isAbsoluteUrl(systemId)) {
+ // 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);
+ if (systemId != null)
+ s.setSystemId(systemId);
+ Source result = new SAXSource(xr, s);
+ return result;
+ } else {
+ // go through DOM to maintain full control over entities
+ InputSource s = new InputSource((Reader) o);
+ s.setSystemId(systemId);
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ db.setEntityResolver(
+ new ParseSupport.JstlEntityResolver(pageContext));
+ return new DOMSource(db.parse(s));
+ }
+ } 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());
}
}
@@ -293,7 +318,7 @@
//*********************************************************************
- // Private utility class
+ // Private utility classes
/**
* A Writer based on a wrapped Writer but ignoring requests to
@@ -309,4 +334,44 @@
w.write(cbuf, off, len);
}
}
+
+ //*********************************************************************
+ // JSTL-specific URIResolver class
+
+ /** Lets us resolve relative external entities. */
+ private static class JstlUriResolver implements URIResolver {
+ private final PageContext ctx;
+ public JstlUriResolver(PageContext ctx) {
+ this.ctx = ctx;
+ }
+ public Source resolve(String href, String base)
+ throws TransformerException {
+ // pass if we don't have a systemId
+ if (href == null)
+ return null;
+
+ // we're only concerned with relative URLs
+ if (ImportSupport.isAbsoluteUrl(href))
+ return null;
+
+ // for relative URLs, load and wrap the resource.
+ // don't bother checking for 'null' since we specifically want
+ // the parser to fail if the resource doesn't exist
+ InputStream s;
+ if (href.startsWith("/")) {
+ s = ctx.getServletContext().getResourceAsStream(href);
+ if (s == null)
+ throw new TransformerException(href);
+ } else {
+ String pagePath =
+ ((HttpServletRequest) ctx.getRequest()).getServletPath();
+ String basePath =
+ pagePath.substring(0, pagePath.lastIndexOf("/"));
+ s = ctx.getServletContext().getResourceAsStream(
+ basePath + "/" + href);
+ }
+ return new StreamSource(s);
+ }
+ }
+
}
1.6 +12 -14 jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/el/xml/ParseTag.java
Index: ParseTag.java
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/el/xml/ParseTag.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ParseTag.java 12 Mar 2002 23:28:47 -0000 1.5
+++ ParseTag.java 17 Apr 2002 12:42:39 -0000 1.6
@@ -74,9 +74,9 @@
//*********************************************************************
// 'Private' state (implementation details)
- private String xmlText_; // stores EL-based property
- private String xmlUrl_; // stores EL-based property
- private String filter_; // stores EL-based property
+ private String xml_; // stores EL-based property
+ private String systemId_; // stores EL-based property
+ private String filter_; // stores EL-based property
//*********************************************************************
@@ -122,12 +122,12 @@
this.filter_ = filter_;
}
- public void setXmlText(String xmlText_) {
- this.xmlText_ = xmlText_;
+ public void setXml(String xml_) {
+ this.xml_ = xml_;
}
- public void setXmlUrl(String xmlUrl_) {
- this.xmlUrl_ = xmlUrl_;
+ public void setSystemId(String systemId_) {
+ this.systemId_ = systemId_;
}
@@ -137,7 +137,7 @@
// (re)initializes state (during release() or construction)
private void init() {
// null implies "no expression"
- filter_ = xmlText_ = xmlUrl_ = null;
+ filter_ = xml_ = systemId_ = null;
}
/* Evaluates expressions as necessary */
@@ -150,12 +150,10 @@
* propagate up.
*/
- xmlText = ExpressionUtil.evalNotNull(
- "parse", "xmlText", xmlText_, Object.class, this, pageContext);
- xmlUrl = (String) ExpressionUtil.evalNotNull(
- "parse", "xmlUrl", xmlUrl_, String.class, this, pageContext);
- if (xmlUrl_ != null && (xmlUrl == null || xmlUrl.equals("")))
- throw new NullAttributeException("import", "xmlUrl");
+ xml = ExpressionUtil.evalNotNull(
+ "parse", "xml", xml_, Object.class, this, pageContext);
+ systemId = (String) ExpressionUtil.evalNotNull(
+ "parse", "systemId", systemId_, String.class, this, pageContext);
try {
filter = (XMLFilter) ExpressionUtil.evalNotNull(
1.4 +23 -28 jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/el/xml/TransformTag.java
Index: TransformTag.java
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/el/xml/TransformTag.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TransformTag.java 12 Mar 2002 23:33:45 -0000 1.3
+++ TransformTag.java 17 Apr 2002 12:42:39 -0000 1.4
@@ -75,10 +75,10 @@
//*********************************************************************
// 'Private' state (implementation details)
- private String xmlText_; // stores EL-based property
- private String xmlUrl_; // stores EL-based property
- private String xsltText_; // stores EL-based property
- private String xsltUrl_; // stores EL-based property
+ private String xml_; // stores EL-based property
+ private String xmlSystemId_; // stores EL-based property
+ private String xslt_; // stores EL-based property
+ private String xsltSystemId_; // stores EL-based property
private String result_; // stores EL-based property
@@ -116,23 +116,23 @@
// Accessor methods
// for EL-based attribute
- public void setXmlText(String xmlText_) {
- this.xmlText_ = xmlText_;
+ public void setXml(String xml_) {
+ this.xml_ = xml_;
}
// for EL-based attribute
- public void setXmlUrl(String xmlUrl_) {
- this.xmlUrl_ = xmlUrl_;
+ public void setXmlSystemId(String xmlSystemId_) {
+ this.xmlSystemId_ = xmlSystemId_;
}
// for EL-based attribute
- public void setXsltText(String xsltText_) {
- this.xsltText_ = xsltText_;
+ public void setXslt(String xslt_) {
+ this.xslt_ = xslt_;
}
// for EL-based attribute
- public void setXsltUrl(String xsltUrl_) {
- this.xsltUrl_ = xsltUrl_;
+ public void setXsltSystemId(String xsltSystemId_) {
+ this.xsltSystemId_ = xsltSystemId_;
}
/* Removed for RI 0.5
@@ -154,7 +154,7 @@
// (re)initializes state (during release() or construction)
private void init() {
// null implies "no expression"
- xmlText_ = xmlUrl = xsltText_ = xsltUrl_ = result_ = null;
+ xml_ = xmlSystemId = xslt_ = xsltSystemId_ = result_ = null;
}
/* Evaluates expressions as necessary */
@@ -167,24 +167,19 @@
* propagate up.
*/
- xmlText = ExpressionUtil.evalNotNull(
- "transform", "xmlText", xmlText_, Object.class, this, pageContext);
- xmlUrl = (String) ExpressionUtil.evalNotNull(
- "transform", "xmlUrl", xmlUrl_, String.class, this, pageContext);
- xsltText= ExpressionUtil.evalNotNull(
- "transform", "xsltText", xsltText_, Object.class, this,
+ xml = ExpressionUtil.evalNotNull(
+ "transform", "xml", xml_, Object.class, this, pageContext);
+ xmlSystemId = (String) ExpressionUtil.evalNotNull(
+ "transform", "xmlSystemId", xmlSystemId_, String.class,
+ this, pageContext);
+ xslt= ExpressionUtil.evalNotNull(
+ "transform", "xslt", xslt_, Object.class, this,
pageContext);
- xsltUrl = (String) ExpressionUtil.evalNotNull(
- "transform", "xsltUrl", xsltUrl_, String.class, this, pageContext);
-// transformer = (Transformer) ExpressionUtil.evalNotNull(
-// "transform", "transformer", transformer_, Transformer.class,
-// this, pageContext);
+ xsltSystemId = (String) ExpressionUtil.evalNotNull(
+ "transform", "xsltSystemId", xsltSystemId_, String.class,
+ this, pageContext);
result = (Result) ExpressionUtil.evalNotNull(
"transform", "result", result_, Result.class, this, pageContext);
- if (xmlUrl_ != null && (xmlUrl == null || xmlUrl.equals("")))
- throw new NullAttributeException("transform", "xmlUrl");
- if (xsltUrl_ != null && (xsltUrl == null || xsltUrl.equals("")))
- throw new NullAttributeException("transform", "xsltUrl");
}
}
1.3 +4 -4 jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/rt/xml/ParseTag.java
Index: ParseTag.java
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/rt/xml/ParseTag.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ParseTag.java 4 Feb 2002 02:39:51 -0000 1.2
+++ ParseTag.java 17 Apr 2002 12:42:39 -0000 1.3
@@ -73,12 +73,12 @@
// Accessor methods
// for tag attribute
- public void setXmlText(Object xml) throws JspTagException {
- this.xmlText = xml;
+ public void setXml(Object xml) throws JspTagException {
+ this.xml = xml;
}
- public void setXmlUrl(String url) throws JspTagException {
- this.xmlUrl = url;
+ public void setSystemId(String systemId) throws JspTagException {
+ this.systemId = systemId;
}
// for tag attribute
1.3 +8 -15 jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/rt/xml/TransformTag.java
Index: TransformTag.java
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/rt/xml/TransformTag.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TransformTag.java 4 Feb 2002 02:39:51 -0000 1.2
+++ TransformTag.java 17 Apr 2002 12:42:39 -0000 1.3
@@ -74,31 +74,24 @@
// Accessor methods
// for tag attribute
- public void setXmlText(Object xmlText) throws JspTagException {
- this.xmlText = xmlText;
+ public void setXml(Object xml) throws JspTagException {
+ this.xml = xml;
}
// for tag attribute
- public void setXmlUrl(String xmlUrl) throws JspTagException {
- this.xmlUrl = xmlUrl;
+ public void setXmlSystemId(String xmlSystemId) throws JspTagException {
+ this.xmlSystemId = xmlSystemId;
}
// for tag attribute
- public void setXsltText(Object xsltText) throws JspTagException {
- this.xsltText = xsltText;
+ public void setXslt(Object xslt) throws JspTagException {
+ this.xslt = xslt;
}
// for tag attribute
- public void setXsltUrl(String xsltUrl) throws JspTagException {
- this.xsltUrl = xsltUrl;
+ public void setXsltSystemId(String xsltSystemId) throws JspTagException {
+ this.xsltSystemId = xsltSystemId;
}
-
- /* Removed for RI 0.5
- // for tag attribute
- public void setTransformer(Transformer transformer) throws JspTagException {
- this.transformer = transformer;
- }
- */
// for tag attribute
public void setResult(Result result) throws JspTagException {
1.3 +3 -15 jakarta-taglibs/standard/src/org/apache/taglibs/standard/tei/XmlTransformTEI.java
Index: XmlTransformTEI.java
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tei/XmlTransformTEI.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XmlTransformTEI.java 4 Feb 2002 02:39:51 -0000 1.2
+++ XmlTransformTEI.java 17 Apr 2002 12:42:39 -0000 1.3
@@ -65,25 +65,13 @@
*/
public class XmlTransformTEI extends TagExtraInfo {
- final private static String XML_TEXT = "xmlText";
- final private static String XML_URL = "xmlUrl";
- final private static String XSLT_TEXT = "xsltText";
- final private static String XSLT_URL = "xsltUrl";
+ final private static String XSLT = "xslt";
final private static String RESULT = "result";
final private static String VAR = "var";
public boolean isValid(TagData us) {
- // disallow both XML_TEXT and XML_URL
- if (Util.isSpecified(us, XML_TEXT) && Util.isSpecified(us, XML_URL))
- return false;
-
- // disallow both XSLT_TEXT and XSLT_URL ...
- if (Util.isSpecified(us, XSLT_TEXT) && Util.isSpecified(us, XSLT_URL))
- return false;
-
- // ... but require at least one of XSLT_TEXT or XSLT_URL
- if (!(Util.isSpecified(us, XSLT_TEXT)
- || Util.isSpecified(us, XSLT_URL)))
+ // require XSLT
+ if (!Util.isSpecified(us, XSLT))
return false;
// disallow both VAR and RESULT
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>