[
http://issues.apache.org/jira/browse/XALANJ-2130?page=comments#action_66890 ]
Brian Minchau commented on XALANJ-2130:
---------------------------------------
Two things don't work properly. First we can't set cdata-section-names using
the {uri}localname format within the stylesheet, e.g.:
<?xml version='1.0'?>
<xsl:stylesheet version='1.0'>
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:xalan='http://xml.apache.org/xalan'
xmlns:prfx='uri1'>
<xsl:output method='xml' indent='yes' xalan:indent-amount='3'
cdata-section-elements='{uri1}b1 b2' />
<xsl:template match='/'>
<out>
<prfx:b1>in b1</prfx:b1>
<b2>in b2</b2>
<prfx:b3>in b3</prfx:b3>
<b4>in b4</b4>
</out>
</xsl:template>
</xsl:stylesheet>
This works for Xalan-J interpretive, but XSLTC doesn't like the
'{uri1}b1 b2' attribute value. So a fix is needed for that.
Secondly, with that fixed, the override from JAXP does not work properly,
also due to it not parsing the {} at all.
Here is a testcase for that:
static void case2() throws TransformerException, IOException {
final javax.xml.transform.TransformerFactory tFactory;
tFactory = new org.apache.xalan.xsltc.trax.TransformerFactoryImpl();
final javax.xml.transform.Transformer transformer;
StringReader sheet = new StringReader(
"<?xml version='1.0'?>\n"+
"<xsl:stylesheet version='1.0'\n"+
" xmlns:xsl='http://www.w3.org/1999/XSL/Transform'\n"+
" xmlns:xalan='http://xml.apache.org/xalan'\n"+
" xmlns:prfx='uri1'>\n"+
"\n"+
"<xsl:output method='xml' indent='yes' xalan:indent-amount='3' \n"+
" cdata-section-elements='{uri1}b1 b2' />\n" +
"<xsl:template match='/'>\n"+
"<out>\n"+
"<prfx:b1>in b1</prfx:b1>\n"+
"<b2>in b2</b2>\n"+
"<prfx:b3>in b3</prfx:b3>\n"+
"<b4>in b4</b4>\n"+
"</out>\n"+
"</xsl:template>\n"+
"</xsl:stylesheet>");
StreamSource stylesheet = new StreamSource(sheet);
transformer = tFactory.newTransformer(stylesheet);
transformer.setOutputProperty(
"cdata-section-elements","b4 {uri1}b3");
StringWriter sw = new StringWriter();
StringReader sr = new StringReader(
"<?xml version='1.0' ?><doc/>");
StreamResult strmrslt = new StreamResult(sw);
StreamSource strmsrc = new StreamSource(sr);
transformer.transform(strmsrc, strmrslt);
sw.flush();
String out = sw.toString();
sw.close();
System.out.println("=================================");
System.out.println(out);
System.out.println("=================================");
}
> cdata-section-elements are not properly set via JAXP
> ----------------------------------------------------
>
> Key: XALANJ-2130
> URL: http://issues.apache.org/jira/browse/XALANJ-2130
> Project: XalanJ2
> Type: Bug
> Reporter: Brian Minchau
> Assignee: Brian Minchau
>
> Section 16. of the XSLT 1.0 recommendation ( see http://www.w3.org/TR/xslt )
> says this:
> <<
> A stylesheet may contain multiple xsl:output elements and may include or
> import stylesheets that also contain xsl:output elements. All the xsl:output
> elements occurring in a stylesheet are merged into a single effective
> xsl:output element. For the cdata-section-elements attribute, the effective
> value is the union of the specified values. For other attributes, the
> effective value is the specified value with the highest import precedence. It
> is an error if there is more than one such value for an attribute. An XSLT
> processor may signal the error; if it does not signal the error, if should
> recover by using the value that occurs last in the stylesheet.
> >>
> Even after this is done one can use the JAXP API
> Transformer.setOutputProperty(name,value) or
> Transformer.setOutputProperty(java.util.Properties) to override values in the
> stylesheet, that would be in its "single effective merged xsl:output element".
> In the spirit of what the stylesheet does, it would seem that if a
> cdata-section-elements property is set, it should not override the
> stylesheets set of sections, but be a union with it, just as the xsl:output
> cdata-sections-elements form an effective union. This is unlike other
> xsl:output attributes.
> The effective xsl:output attributes can be modified with mulitple calls to
> Transformer.setOuputProperty(String name, String value) and/or
> Transformer.setOutputProperty(java.util.Properties)
> However the serializer is brittle with respect to multiple such calls namely:
> - cdata-section-elements from JAXP do merge with the stylesheets values, they
> replace the stylesheets values
> - Writers can be lost
> - properties with namespaces, where the name part of the property is of the
> form
> "{uri}localname" are not properly handled, (i.e. it doesn't parse the uri
> from within the curly braces).
> The code needs some re-work to make it robust.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]