[xml] Text-Entities and Namespaces?
- From: Morus Walter <morus walter tanto-xipolis de>
- To: xml gnome org
- Subject: [xml] Text-Entities and Namespaces?
- Date: Fri, 11 Jan 2002 15:52:38 +0100
Hi,
though the following sample is connected to xslt, the problem itself
seems to be a libxml issue, so I write here:
I was trying to beautify some xslt output be adding linebreaks in the
stylesheet. Now I didn't want to write <xsl:text>
</xsl:text>
for every line feed, so I decided to use an entity instead.
That is, I added
<!DOCTYPE xsl:stylesheet [
<!ENTITY LF '<xsl:text>
</xsl:text>'>
]>
to the stylesheet.
Unfortunately libxml seems to have a problem with the namespace, used
in the entity:
The complete stylesheet is
--- test.xsl ---
<?xml version="1.0"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY LF '<xsl:text>
</xsl:text>'>
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="no" encoding="ISO-8859-1" method="xml"/>
<xsl:template match="bla">
<out>&LF;
<xsl:apply-templates/>
&LF;</out>
</xsl:template>
</xsl:stylesheet>
----------------
and I have some xml file
--- test.xml ---
<bla>fasel</bla>
----------------
When I call xsltproc I get
Entity: line 1: warning: Namespace prefix xsl is not defined
<xsl:text>
^
compilation error: file test.xsl line 1 element text
Namespaces prefix Ìôÿ¿sí`ehR` Ìôÿ¿aí`@tõÿ¿#¨# used for multiple namespaces
compilation error: file test.xsl element text
Namespaces prefix Ìôÿ¿sí`ehR` Ìôÿ¿aí`@tõÿ¿#¨# used for multiple namespaces
<?xml version="1.0" encoding="ISO-8859-1"?>
<out><text/>fasel<text/></out>
One can get around this problem by defining the namespace within the
entity (<!ENTITY LF '<xsl:text xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
</xsl:text>'>).
Xalan however does not require such means:
(1221 ~/libxml) xalan -Q -XSL test.xsl -IN test.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<out>
fasel
</out>
xmllint --noent test.xsl
complains about an undefined namespace and drops the prefix.
(1223 ~/libxml) xmllint --noent test.xsl
Entity: line 1: warning: Namespace prefix xsl is not defined
<xsl:text>
^
...
<out><text>
</text>
<xsl:apply-templates/>
<text>
</text></out>
...
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]