You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Jean-Claude Vogel <vo...@gmail.com> on 2008/05/26 14:35:59 UTC
Putting XMLNS declarations at begining
Hello guys,
I use an XSLT transformation in my sitemap and an XML serializer to generate
the HTTP response.
My pipe :
<map:match pattern="program">
<map:generate type="programGenerator"/>
-- Here, my stream exists and has to be transformed --
<map:call resource="myTransformer"/>
<map:serialize type="xml"/>
</map:match>
My transformer :
<map:resource name="myTransformer">
<map:transform type="xslt" src="myXSLT.xslt"/>
</map:resource>
My serializer :
<map:serializer logger="sitemap.serializer.xml" mime-type="text/html;
charset=UTF-8" name="xml"
src="org.apache.cocoon.serialization.XMLSerializer">
<encoding>UTF-8</encoding>
<omit-xml-declaration>no</omit-xml-declaration>
<indent>yes</indent>
</map:serializer>
My XSLT file :
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xxx_CD="urn:xxx:aa:schema:20050901"
xmlns:xxx_TV="urn:xxx:bb:schema:20050901"
xmlns:xxx_st="urn:xxx:cc:schema:20050901"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="schema.xsd"
>
....
Here is my the output data when I use my pipe :
<?xml version="1.0" encoding="UTF-8" ?>
<xxx_GRID date="2008-05-26" name="schema.xsd">
<balise>
<xxx:Content xmlns:xxx_CD="*urn:xxx:aa:schema:20050901*" attr1="248315"attr2
="ffffffffffff">
.....
</balise>
My problem is the xmlns:xxx_CD="*urn:xxx:aa:schema:20050901*", I would like
to have this namespace declaration one time for all at the begining of my
output XML file but I don't know if I have to modify the serializer, the
cocoon transformer, the XSLT file or something else. In fact for each
xxx:Content tag this declaration is redonded.
Can somebody help me about this problem ?
Thanks,
Jean-Claude
Re: Putting XMLNS declarations at begining
Posted by Betty Harvey <ha...@eccnet.com>.
Hi Jean-Claude:
You can put the namespace declaration in the XSLT and at the root
element solve your problem.
If the element <balise> isn't in the same namespace you will also need
to made a namespace declaration for it.
<xxx_GRID
xmlns="urn:balise"
xmlns:xxx_CD="urn:xxx:aa:schema:20050901"
date="2008-05-26"
name="schema.xsd">
<balise>
...
</xxx_GRID>
The element <xxx_GRID> and <balise> elements will belong to the
default namespace "urn:balise" and any element prefixed by 'xxx'
will belog to the "urn:xxx:aa:schema:20050901" namespace.
When writing your XSLT you will need to aware of the namespace
and use the prefix when creating your templates.
Hope this helps!
Betty
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
Betty Harvey | Phone: 410-787-9200 FAX: 9830
Electronic Commerce Connection, Inc. |
harvey@eccnet.com | Washington,DC SGML/XML Users Grp
URL: http://www.eccnet.com | http://www.eccnet.com/xmlug/
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\/\/
Help Mac fight MLD (http://www.macsteam.org)
Mark your calendar for October 28th (http://www.macsteam.org/BullROast.aspx)
Jean-Claude Vogel wrote:
> Hello guys,
>
> I use an XSLT transformation in my sitemap and an XML serializer to
> generate
> the HTTP response.
>
> My pipe :
> <map:match pattern="program">
> <map:generate type="programGenerator"/>
> -- Here, my stream exists and has to be transformed --
> <map:call resource="myTransformer"/>
> <map:serialize type="xml"/>
> </map:match>
>
> My transformer :
> <map:resource name="myTransformer">
> <map:transform type="xslt" src="myXSLT.xslt"/>
> </map:resource>
>
> My serializer :
> <map:serializer logger="sitemap.serializer.xml" mime-type="text/html;
> charset=UTF-8" name="xml"
> src="org.apache.cocoon.serialization.XMLSerializer">
> <encoding>UTF-8</encoding>
> <omit-xml-declaration>no</omit-xml-declaration>
> <indent>yes</indent>
> </map:serializer>
>
>
> My XSLT file :
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xxx_CD="urn:xxx:aa:schema:20050901"
> xmlns:xxx_TV="urn:xxx:bb:schema:20050901"
> xmlns:xxx_st="urn:xxx:cc:schema:20050901"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:noNamespaceSchemaLocation="schema.xsd"
> >
> ....
>
> Here is my the output data when I use my pipe :
> <?xml version="1.0" encoding="UTF-8" ?>
> <xxx_GRID date="2008-05-26" name="schema.xsd">
> <balise>
> <xxx:Content xmlns:xxx_CD="*urn:xxx:aa:schema:20050901*"
> attr1="248315"attr2
> ="ffffffffffff">
> .....
> </balise>
>
> My problem is the xmlns:xxx_CD="*urn:xxx:aa:schema:20050901*", I would
> like
> to have this namespace declaration one time for all at the begining of my
> output XML file but I don't know if I have to modify the serializer, the
> cocoon transformer, the XSLT file or something else. In fact for each
> xxx:Content tag this declaration is redonded.
>
> Can somebody help me about this problem ?
>
> Thanks,
> Jean-Claude
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org