You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by 32...@gmail.com on 2006/07/28 16:24:11 UTC

Bring xml in better "shape"

Hi,
I want to offer my visitors the possibility to get the content they are
reading as a XML File.
Sadly when using the xml serializer, the output xml does not look very
appealing. See yourself:
http://img127.imageshack.us/my.php?image=xmlos6.png
Can I somehow improve that?

2nd:
as you can see, the root element (document) has the sql namespace. Why is it
displayed there? I mean, I have it in my transforming xsl file, like that:
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sql="http://apache.org/cocoon/SQL/2.0">

but why is it displayed in the final xml?

Thanks
Marco

Re: Bring xml in better "shape"

Posted by Nils Kaiser <Ni...@gmx.net>.
If you just want your visitors to be able to view the data (in a web 
page) instead of beeing able to save the xml to a file for later 
processing, you can also transform the xml stream using the 
"xml2html.xslt" stylesheet (cocoon/webapp/stylesheets/system) and 
serialize it using the HTML serializer.

It gives you a nice looking html representation of your xml data, with 
syntax highlighting and openable/closable sub-elements via javascript.

Greetings,

Nils


321los@gmail.com schrieb:
> Hello,
> that works. Not 100% but enough to satisfy my needs. Appreciate your help
> Marco
>
>


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


Re: Bring xml in better "shape"

Posted by 32...@gmail.com.
Hello,
that works. Not 100% but enough to satisfy my needs. Appreciate your help
Marco


2006/7/28, Jeroen Reijn <j....@hippo.nl>:
>
> Hi Marco,
>
>
>
> > Can I somehow improve that?
>
> Yes, you can try to indent your XML. It's an option of the XMLSerializer.
>
> http://cocoon.apache.org/2.1/userdocs/xml-serializer.html
>
> >
> > 2nd:
> > as you can see, the root element (document) has the sql namespace. Why
> > is it displayed there? I mean, I have it in my transforming xsl file,
> > like that:
> > <?xml version="1.0" encoding="iso-8859-1"?>
> > <xsl:stylesheet version="1.0"
> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform
> > <http://www.w3.org/1999/XSL/Transform>"
> > xmlns:sql="http://apache.org/cocoon/SQL/2.0">
> >
> > but why is it displayed in the final xml?
>
> Did you put the exclude-result-prefixes="" within the your XSL?
>
> If that doesn't help you could always put a stripnamespaces xsl in front
> of your XML serializer.
>
> For more information see: http://www.planetcocoon.com/node/2425
>
> I hope that helps.
>
> Regards,
>
> Reijn
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>

Re: Bring xml in better "shape"

Posted by Leszek Gawron <lg...@mobilebox.pl>.
Jeroen Reijn wrote:
> Hi Marco,
> 
> 
> 
>> Can I somehow improve that?
> 
> Yes, you can try to indent your XML. It's an option of the XMLSerializer.
> 
> http://cocoon.apache.org/2.1/userdocs/xml-serializer.html
> 
>>
>> 2nd:
>> as you can see, the root element (document) has the sql namespace. Why 
>> is it displayed there? I mean, I have it in my transforming xsl file, 
>> like that:
>> <?xml version="1.0" encoding="iso-8859-1"?>
>> <xsl:stylesheet version="1.0"
>> xmlns:xsl="http://www.w3.org/1999/XSL/Transform 
>> <http://www.w3.org/1999/XSL/Transform>"
>> xmlns:sql="http://apache.org/cocoon/SQL/2.0">
>>
>> but why is it displayed in the final xml?
> 
> Did you put the exclude-result-prefixes="" within the your XSL?
this will not work...

> 
> If that doesn't help you could always put a stripnamespaces xsl in front 
> of your XML serializer.
this will:

> <?xml version="1.0"?>
> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:template match="content">
> 	<xsl:element name="{local-name()}">
> 		<xsl:apply-templates/>
> 	</xsl:element>
> </xsl:template>
> <xsl:template match="row">
> 	<xsl:element name="{local-name()}">
>         <xsl:for-each select="./*">
>             <xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>
>         </xsl:for-each>
> 	</xsl:element>
> </xsl:template>
> <xsl:template match="*">
> 	<xsl:element name="{local-name()}">
> 		<xsl:for-each select="@*">
> 			<xsl:attribute name="{local-name()}">
> 				<xsl:value-of select="."/>
> 			</xsl:attribute>
> 		</xsl:for-each>
> 		<xsl:apply-templates/>
> 	</xsl:element>
> </xsl:template>
> </xsl:stylesheet>


-- 
Leszek Gawron                                      lgawron@mobilebox.pl
IT Manager                                         MobileBox sp. z o.o.
+48 (61) 855 06 67                              http://www.mobilebox.pl
mobile: +48 (501) 720 812                       fax: +48 (61) 853 29 65

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


Re: Bring xml in better "shape"

Posted by Jeroen Reijn <j....@hippo.nl>.
Hi Marco,



> Can I somehow improve that?

Yes, you can try to indent your XML. It's an option of the XMLSerializer.

http://cocoon.apache.org/2.1/userdocs/xml-serializer.html

> 
> 2nd:
> as you can see, the root element (document) has the sql namespace. Why 
> is it displayed there? I mean, I have it in my transforming xsl file, 
> like that:
> <?xml version="1.0" encoding="iso-8859-1"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform 
> <http://www.w3.org/1999/XSL/Transform>"
> xmlns:sql="http://apache.org/cocoon/SQL/2.0">
> 
> but why is it displayed in the final xml?

Did you put the exclude-result-prefixes="" within the your XSL?

If that doesn't help you could always put a stripnamespaces xsl in front 
of your XML serializer.

For more information see: http://www.planetcocoon.com/node/2425

I hope that helps.

Regards,

Reijn

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