XSLT + java: namespace problem

Guillon Benoit <[email protected]> Thu, 08 Sep 2005 18:06:47 +0200
Newsgroups gmane.comp.openoffice.devel.xml
Message-ID <[email protected]>
Hello,

I'm having troubles with the xmerge framework when I try to export a sxw 
document using an XSL stylesheet. When I start my Java application 
outside OpenOffice everything works fine but when I use it as a filter 
in OOo 1.1.4, the XPATH expressions do not match when I use namespaces 
but match when I don't use namespaces.

Example:
<xsl:value-of select="count(/document-content/*)"/> will return 0 
outside OOo and 4 in OOo.
<xsl:value-of select="count(/office:document-content/*)"/> will return 4 
outside OOo and 0 in OOo.

It must be a problem of XML parser configuration but I really don't know 
where I can fix it.

This is a part of my Java code:

ConvertData cd = new ConvertData();
URL url = this.getClass().getResource("/ooo2dtbook.xsl"); /* where my 
XSL is */
InputStream xsl_is = url.openStream();

/* ... */

DOMDocument dd = new DOMDocument(inputDocument.getName(), ".xml");  /* 
inputDocument is received from the xmerge framework */
TransformerFactory tf = TransformerFactory.newInstance();
       
try{
    DOMResult dr = new DOMResult();
    DOMSource ds = new DOMSource(inputDocument.getContentDOM());
           
    Transformer t = tf.newTransformer(new StreamSource(xsl_is));
           
    t.transform(ds, dr);
    dd.setContentDOM(dr.getNode());
}

/* ... */

My XSLT code has nothing special ... and works when I launch it in Xalan 
and Saxon.

Thanks

Benoit Guillon.