xsl-list
[Top] [All Lists]

Re: [xsl] XSLT transformation using counters

2011-04-26 11:25:04
Bubba O'Reily wrote:

ok. I'm not sure which one to use in my case. Using the below as an example:


   <xsl:variable name="counter">
    <xsl:number level="single" format="1" />
   </xsl:variable>

   <xsl:element name="hd{$counter}">
    <xsl:apply-templates/>
   </xsl:element>
   <xsl:text disable-output-escaping="yes">&gt;</xsl:text>


In the output file I actually need to generate the following. In this case 
probably in
this case the<xsl:output method="text" is the way to go?


<PStyle:hd1>
<PStyle:hd2>

You can of course use
<xsl:element name="PStyle:hd{$counter}" namespace="http://example.com/style";>
      <xsl:apply-templates/>
    </xsl:element>
if you want to output elements in a certain namespace and with a certain prefix. You might also want to declare
    xmlns:PStyle="http://example.com/style";
on the xsl:stylesheet element to ensure the declaration is output on the root of the result tree and not on each hd element.



--

        Martin Honnen
        http://msmvps.com/blogs/martin_honnen/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--