Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Not A Bug
-
Affects Version/s: 1.7.5
-
Fix Version/s: None
-
Component/s: XML Processing
-
Labels:None
-
Environment:- Windows XP
- Java 1.6.0_21
-
Testcase included:yes
-
Number of attachments :
Description
See example below which executes an XSL transformation. Problem is, that content in curly braces are / seem to be evaluated as variables by Groovy (or Xalan).
If I execute the code as is, I get following error:
FEHLER: 'Syntaxfehler in 'null'.'
SCHWER WIEGENDER FEHLER: 'Die Formatvorlage konnte nicht kompiliert werden.'
Caught: javax.xml.transform.TransformerConfigurationException: Die Formatvorlage konnte nicht kompiliert werden.
at TestXalanCurlyBraces.main(TestXalanCurlyBracesGroovy.groovy:63)
When removing the curly braces in the xsl-content of 'get,set-by-create' the transformation get executed but in the output the attribute value of the pmPerms is empty! Thus, it looks as if
{get} is tried to resolve to a valid variable! Further on, this would explain, why something like {get,set-by-create} is invalid. (There can't be a variable name like 'get,set-by-create'.)Though it doesn't look like a Groovy problem I couldn't reproduce the problem in Java.
- Is the problem reproducible?
- Workaround?
- Fix needed?
Thanks,
Peter
import java.io.FileReader
import java.io.FileWriter
import java.io.IOException
import javax.xml.transform.Transformer
import javax.xml.transform.TransformerException
import javax.xml.transform.TransformerFactory
import javax.xml.transform.stream.StreamResult
import javax.xml.transform.stream.StreamSource
public class TestXalanCurlyBraces {
static def xmlContent = '''<?xml version="1.0" encoding="UTF-8"?>
<Attributes xmlns="http://www.ascom.com/opentas"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.ascom.com/opentas AttrDefs.xsd">
<SimpleAttribute attrIdName="passwordNeverExpires"
pmPerms="{get,replace}"
nsPerms="{get,replace}"/>
</Attributes>
'''
static def xslContent = '''<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:otas="http://www.ascom.com/opentas">
<xsl:output method="xml" standalone="yes"/>
<Unable to render embedded object: File (-- XSLT Template to copy anything, priority="-1" -> apply only if no other rule applies) not found. -->
<xsl:template match="@*|node()" priority="-1">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="//otas:Attributes/otas:SimpleAttribute[last()]">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
<xsl:text disable-output-escaping="yes">
<otas:SimpleAttribute2 attrIdName="strongAuth" pmPerms="{get}
"
nsPerms="
"/>
</xsl:text>
</xsl:template>
</xsl:stylesheet>
'''
/**
- @param args
- @throws IOException
- @throws TransformerException
*/
public static void main(String[] args) throws IOException, TransformerException { TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(new StreamSource(new StringReader(xslContent))); transformer.transform(new StreamSource(new StringReader(xmlContent)), new StreamResult(System.out)); System.out.println("Done."); }}
Actually I get the same error when running this as Java. Here is the code I used for both: