|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Another problem with namespaces and XSL
Hello everybody,
I'm having another problem with namespaces and XSL.
I'm making a stylesheet that generate another stylesheet.
I want to generate the "desired XML output" of the "son" stylesheet,
that is generated by "mother" one.
The problem is:
* In the "son" stylesheet, is shown
xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias" in the axsl:key
and axsl:value-of elements. Why this happens? I don't desire this. If
this isn't printed in output, the desired XML output is generated.
I'm sending some examples of this stylesheets. The input for the
stylesheets is the XML file above.
Regards,
------------------------------------
Giovani Rubert Librelotto
Ph.D. Student
Universidade do Minho
Braga - Portugal
grl@xxxxxxxxxxxx
The XML input file:
<root>
<Categories>
<CategoryID>0</CategoryID>
<CategoryName>Food</CategoryName>
<Description>Food that the people eat.</Description>
<Picture>R0lGODlhcgGSALMAAAQCAEMmCZtuMFQxDS8b</Picture>
</Categories>
<Categories>
<CategoryID>1</CategoryID>
<CategoryName>Clothes</CategoryName>
<Description>Clothes that the people uses.</Description>
<Picture>R0lGODlhcgGSALMAAAQCAEMmCZtuMFQxDS8b</Picture>
</Categories>
</root>
"Mother" stylesheet:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias"
xmlns:xlink="http://www.w3.org/1999/xlink">
<xsl:namespace-alias stylesheet-prefix="axsl" result-prefix="xsl"/>
<xsl:output method="xml" omit-xml-declaration="no" standalone="yes"
indent="yes"/>
<xsl:template match="text()" priority="-1"/>
<xsl:template match="/">
<axsl:stylesheet version="1.0">
<axsl:output method="xml" omit-xml-declaration="no"
encoding="iso-8859-1" standalone="yes" indent="yes"/>
<xsl:for-each select="/root">
<xsl:element name="axsl:key">
<xsl:attribute name="name">tCategories</xsl:attribute>
<xsl:attribute name="match">Categories</xsl:attribute>
<xsl:attribute name="use">./CategoryID</xsl:attribute>
</xsl:element>
</xsl:for-each>
<axsl:template match="text()" priority="-1"/>
<axsl:template match="/">
<root xmlns:xlink="http://www.w3.org/1999/xlink">
<node>
<ref xlink:href="#products"/>
</node>
<xsl:element name="axsl:value-of">
<xsl:attribute name="select"><xsl:text>key('tCategories',
1)/CategoryName</xsl:text></xsl:attribute>
</xsl:element>
</root>
</axsl:template>
</axsl:stylesheet>
</xsl:template>
</xsl:stylesheet>
Generated "son" stylesheet:
<axsl:stylesheet xmlns:axsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xlink="http://www.w3.org/1999/xlink" version="1.0">
<axsl:output method="xml" omit-xml-declaration="no"
encoding="iso-8859-1" standalone="yes" indent="yes"/>
<axsl:key xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias"
name="tCategories" match="Categories" use="./CategoryID"/>
<axsl:template match="text()" priority="-1"/>
<axsl:template match="/">
<root>
<node>
<ref xlink:href="#products"/>
</node>
<axsl:value-of
xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias"
select="key('tCategories', 1)/CategoryName"/>
</root>
</axsl:template>
</axsl:stylesheet>
Desired "son" stylesheet (whitout
xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias"):
<axsl:stylesheet xmlns:axsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xlink="http://www.w3.org/1999/xlink" version="1.0">
<axsl:output method="xml" omit-xml-declaration="no"
encoding="iso-8859-1" standalone="yes" indent="yes"/>
<axsl:key name="tCategories" match="Categories" use="./CategoryID"/>
<axsl:template match="text()" priority="-1"/>
<axsl:template match="/">
<root>
<node>
<ref xlink:href="#products"/>
</node>
<axsl:value-of select="key('tCategories', 1)/CategoryName"/>
</root>
</axsl:template>
</axsl:stylesheet>
Generated XML output:
<root xmlns:xlink="http://www.w3.org/1999/xlink">
<node>
<ref xlink:href="#products"/>
</node>
<axsl:value-of xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias"
select="key('tCategories', 1)/CategoryName"/>
</root>
Desired XML output:
<root xmlns="http://www.topicmaps.org/xtm/1.0/"
xmlns:xlink="http://www.w3.org/1999/xlink">
<node>
<ref xlink:href="#products"/>
</node>
Clothes
</root>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








