Re: [xslt] namespace URI for child elements



add the following attribute to your stylesheet element:
exclude-result-prefixes="in out"


On Sun, 2002-11-10 at 10:11, Gerhard Dieringer wrote:
> 
> 
> Hi
> 
> I have the following question:
> 
> the following stylesheet:
> --------------------------------------------------------
> <?xml version='1.0'?>
> 
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
>                 xmlns:in="input" 
>                 xmlns:out="output" 
>                 version='1.0'>
> 
>     <xsl:output method="xml" indent="yes" doctype-system="output.dtd"/>
> 
>     <xsl:template match="in:top">
>       <xsl:element name="out:toplevel">
>         <xsl:apply-templates  select="in:sub1"/>
>         <xsl:apply-templates  select="in:sub2"/>
>       </xsl:element>
>       <xsl:text>
> </xsl:text>
>   </xsl:template>
> 
>     <xsl:template match="in:sub1">
>       <xsl:text>
> </xsl:text>
>       <xsl:element name="out:sublevel1">
>         <xsl:value-of  select="concat('data=',@data)"/>
>       </xsl:element>
>       <xsl:text>
> </xsl:text>
>   </xsl:template>
> 
>     <xsl:template match="in:sub2">
>       <xsl:element name="out:sublevel2">
>         <xsl:value-of  select="concat('data=',@data)"/>
>       </xsl:element>
>       <xsl:text>
> </xsl:text>
>   </xsl:template>
> 
>   
> </xsl:stylesheet>
> --------------------------------------------------------
> gives with the following input file:
> --------------------------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <in:top xmlns:in="input">
>   <in:sub1 data="hello"/>
>   <in:sub2 data="world"/>
> </in:top>
> --------------------------------------------------------
> the output:
> --------------------------------------------------------
> <?xml version="1.0"?>
> <!DOCTYPE toplevel SYSTEM "output.dtd">
> <out:toplevel xmlns:out="output">
> <out:sublevel1 xmlns:out="output">data=hello</out:sublevel1>
> <out:sublevel2 xmlns:out="output">data=world</out:sublevel2>
> </out:toplevel>
> --------------------------------------------------------
> Is there a way to avoid the (not needed) namespace-URIs in
> <out:sublevel1> and <out:sublevel2>
> and get the result
> --------------------------------------------------------
> <?xml version="1.0"?>
> <!DOCTYPE toplevel SYSTEM "output.dtd">
> <out:toplevel xmlns:out="output">
> <out:sublevel1>data=hello</out:sublevel1>
> <out:sublevel2>data=world</out:sublevel2>
> </out:toplevel>
> --------------------------------------------------------
> 
> 
> -------
> Gerhard
> 
> 
> _______________________________________________
> xslt mailing list, project page http://xmlsoft.org/XSLT/
> xslt@gnome.org
> http://mail.gnome.org/mailman/listinfo/xslt
> 





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]