Re: [xsl] xsl:element will not create an output element, in any context

Subject: Re: [xsl] xsl:element will not create an output element, in any context
From: N David Brown <orieldave@xxxxxxxxxxxxxx>
Date: Thu, 31 May 2007 22:32:06 +0000
Ok, back from work now, so have had time to test =D

@Abel -

I tried running your Hello World test, and it worked fine =)

I took note of your 'need an html, title... element in the output' comment, and tried using this -

   xsl:stylesheet version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
   xmlns:xhtml="http://www.w3.org/1999/XHTML";>
   <xsl:output method="html"/>

   <xsl:template match="/">
       <html><head><title></title></head><body>
               <ul><xsl:apply-templates/></ul>
       </body></html>
   </xsl:template>

   <xsl:template match="dir">
       <li><xsl:value-of select="text()[1]"/>
           <ul><xsl:apply-templates/></ul>

   </li>
   </xsl:template>

   <xsl:template match="file">
   <li><xsl:value-of select="text()[1]"/></li>
   </xsl:template>

</xsl:stylesheet>


- to transform this -



<root> <dir> tier00 <dir> tier10 <dir> tier20 <file>file0</file> </dir> </dir> </dir> <dir> tier01 <dir> magic <dir> random <file>anotherFile2</file> <file>anotherFile</file> </dir> </dir> <dir> tier11 <dir> tier21 <file>file1</file> </dir> </dir> </dir> </root>


- but it didn't work. Still no elements were output; only the 'value-of's.



@David -



David Carlisle wrote:

<xsl:template match="dir"> <li><xsl:value-of select="text()[1]"/> <ul><xsl:apply-templates/></il> </li> </xsl:template>
I just tried this, and it output only the 'value-of's, nothing more... I tried setting output to 'html', 'xml' and not including the tag at all, but nothing produced the UL and LI elements. I'm transforming using my PHP now, as Abel, suggested, and the content is dumped to a text file so there's no worry I'm missing something that's actually there ;)

Additionally, I tried this latest example with 'xml version="2.0"' declared, but to no avail, regardless of 'html/xml' output attribute value. I also tried all of these tests with this elemented wrapped around the dir template's contents:

   <xsl:element name="test">
   ....
   </xsl:element>

As I said before, I'm viewing the direct, dumped output, so I'm not just failing to observe something that's actually there, I don't think...

So guys, you see why I'm stumped! What should I try next?

- Dave

Current Thread