-
1. Re: JBoss 5.1 JAXB differs regarding XmlAnyElement namespace attributes
ingoschi Aug 23, 2010 7:48 AM (in response to ingoschi)I've created an example implementation.
The welcome page of the deployed jaxbXSLTTest-SNAPSHOT.war shows different results, depending whether it's deployed to JBoss 5.1 or Tomcat 6 with JDK 1.6.
The xml-document before:
{code:xml} <?xml version="1.0" encoding="UTF-8" ?>
<xsltElement xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.org/jaxbXSLTTest ./jaxbXSLTText.xsd"
xmlns="http://www.example.org/jaxbXSLTTest">
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:test="http://example.org/testxlns">
<xsl:template match="test:Test">
<xsl:apply-templates select="test:subTest" />
</xsl:template>
</xsl:stylesheet>
</xsltElement>{code}The schema:
{code:xml} <?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/jaxbXSLTTest"
xmlns:tns="http://www.example.org/jaxbXSLTTest" elementFormDefault="qualified">
<element name="xsltElement" type="tns:xsltType" />
<complexType name="xsltType">
<complexContent>
<extension base="anyType" />
</complexContent>
</complexType>
</schema>{code}
The generated class (javadoc + imports removed)
{code:java}
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "xsltType", propOrder = {
"any"
})
public class XsltType {
@XmlAnyElement
protected List<Element> any;
@XmlAnyAttribute
private Map<QName, String> otherAttributes = new HashMap<QName, String>();
public List<Element> getAny() {
if (any == null) {
any = new ArrayList<Element>();
}
return this.any;
}
public Map<QName, String> getOtherAttributes() {
return otherAttributes;
}
}{code}
The xml-document after unmarshalling and marshalling with JBoss 5.1 :
{code:xml}
<?xml version="1.0" encoding="UTF-8"?>
{code}
<xsltElement xmlns="http://www.example.org/jaxbXSLTTest">
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="" xmlns:ns3="http://www.example.org/jaxbXSLTTest" version="1.0">
<xsl:template match="test:Test">
<xsl:apply-templates select="test:subTest"/>
</xsl:template>
</xsl:stylesheet>
</xsltElement>The included stylesheet misses the namespace declaration xmlns:test="http://example.org/testxlns" that is needed for the xpath expressions.
Is this a (known, maybe already fixed) bug or just different interpretations of specifications? Am I not allowed to use anytype for xslt?
-
jaxbXSLTTest-SNAPSHOT.war 8.7 KB