cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nick <goup...@muss.cis.mcmaster.ca>
Subject XSLT Transformation and namespaces issue
Date Wed, 14 Jul 2004 04:57:27 GMT
Hi everybody,

I experienced a very strange behavior of XSLT transformations when 
trying to prepare an XUpdate query. In particular, such a transformation 
would not keep the name spaces for XUpdate tags.

The set up is the following: I have a remove eXist 1.0 db installed. It 
is perfectly accessible via client and XMLDB protocol. I am able to 
create and delete resources and collectons no problem. I also use topic 
maps (which are just XML files, some of the tags would use xlink:href 
attribute), so the goal is to add a set of tags into a resource that 
contains <topicMap> root tag. This set of tags is generated by an XSLT 
transformation:

<xmldb:query oid="myTexts.xml" type="update" 
xmlns:xmldb="http://apache.org/cocoon/xmldb/1.0">
<xupdate:modifications version="1.0" 
xmlns:xupdate="http://www.xmldb.org/xupdate">
<xupdate:append select="/topicMap" 
xmlns:xupdate="http://www.xmldb.org/xupdate">

<xupdate:element name="topic" xmlns:xupdate="http://www.xmldb.org/xupdate">
<xupdate:attribute name="id" xmlns:xupdate="http://www.xmldb.org/xupdate">
<xsl:value-of select="$textID" xmlns:xlink="http://www.w3.org/1999/xlink"/>
</xupdate:attribute>
<instanceOf>
<topicRef xlink:href="#text" xmlns:xlink="http://www.w3.org/1999/xlink"/>
</instanceOf>
<baseName>
<baseNameString>
<xsl:value-of select="$textLabel"/>
</baseNameString>
</baseName>
<occurrence>
<topicRef xlink:href="#plain-text-format" 
xmlns:xlink="http://www.w3.org/1999/xlink"/>
</instanceOf>
<resourceRef xlink:href="{$textLink}" 
xmlns:xlink="http://www.w3.org/1999/xlink"/>
</occurrence>
<occurrence>
<instanceOf>
<topicRef xlink:href="#notes" xmlns:xlink="http://www.w3.org/1999/xlink"/>
</instanceOf>
<resourceData>
<xsl:value-of select="$notes" xmlns:xlink="http://www.w3.org/1999/xlink"/>
</resourceData>
</occurrence>
</xupdate:element>
</xupdate:append>
</xupdate:modifications>
</xmldb:query>

Here is the pipeline that handles the transformation:

<map:match pattern="addText">
<map:generate type="request"/>
<map:transform src="addTextParam2SourceWrite.xsl">
<map:parameter name="userName" value="TestName"/>
</map:transform>

<map:transform type="xslt" src="addTextParam2-XMLDB.xsl">
<map:parameter name="userName" value="TestName"/>
</map:transform>

<map:transform type="xmldb">
<map:parameter name="base" 
value="xmldb:exist://myhost:8080/exist/xmlrpc/db/cocoon/topicMaps"/>
</map:transform>

<map:serialize type="xml"/>


Once the XSLT transformation takes place, all of the name space 
declarations for the tags beneath <xupdate:modifications> disappear. I 
don’t know if that’s what causes the query to fail, but I attempted to 
skip the xmldb transformer and save the xml output to a file. I manually 
inserted the name spaces into all of the tags, and run it through a 
simple pipeline:

<map:match pattern="createCollection">
<map:generate src="createCollection.xml"/>
<map:transform type="xmldb">
<map:parameter name="base" 
value="xmldb:exist://myhost:8080/exist/xmlrpc/db/test"/>
</map:transform>
<map:serialize type="xml"/>
</map:match>

This query reported to be successfull. What seems to be the problem is 
the missing name spaces (removed by the xslt transformation).

I tried to use Saxon (same problem) and XSLTC (blank output), but it 
didn’t help. I don’t know if that matters, but I also have parameter 
name space-prefixes set to true for the XML parser:

<xml-parser class="org.apache.excalibur.xml.impl.JaxpParser" 
logger="core.xml-parser" pool-grow="4" pool-max="32" pool-min="8">
<parameter name="validate" value="false"/>
<parameter name="name space-prefixes" value="true"/>


Software uses is Cocoon 2.1.5, eXist 1.0, Tomcat 5.0.19

In case there is anybody who experienced the same problem, plsease, 
share your knowledge how to make sure that the name space info is not 
being deleted by XSLT transformation.

Thank you very much in advance.

Best regards,
Nick.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message