1 Reply Latest reply on Aug 23, 2010 7:48 AM by Ingo Schildmann

    JBoss 5.1 JAXB differs regarding XmlAnyElement namespace attributes

    Ingo Schildmann Newbie

      We migrated our Tomcat Web Application to JBoss 5.1. and found a bug,

      because  the JBoss JAXB Implementation seems to behave differently than the JDK  1.6 JAXB Implementation

       

      We want to load an XSLT  stylesheet via a webservice.

      The response is processed with JAXB. An XmlAnyElement contains  the XSLT stylesheet, so we retrieve it with casting the appropiate  "any"-Object to org.w3c.dom.Element.

       

      The problem is that under JBoss 5.1. the Element and  its children have only declaration attributes for its own namespaces but not the  namespaces that are needed additionally for the XPath expressions, so  the stylesheet is now corrupt.

       

      Is this a known problem? Is there a solution? Can we  use a different JAXB-Implementation with JBoss 5.1.?

        • 1. Re: JBoss 5.1 JAXB differs regarding XmlAnyElement namespace attributes
          Ingo Schildmann Newbie

          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"?>
          <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>
          {code}

           

          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?