[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

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 12:17:09 +0000

Thanks for your response, David.

I should have mentioned that I've also tried this:

<xsl:stylesheet .... xmlns:xhtml="http://www.w3.org/1999/XHTML">

...

   <xsl:template match="*">
      <xsl:element name="xhtml:UL>
      <xsl:apply-templates/>
      </xsl:element>
   </xsl:template>

Using this on my <root><dir><file> structure of XML, I get the text nodes output (eg. rootmenudir1file1file2) with no ul tags surrounding. Am I doing something wrong?

This next example produces the same output; no ul tags:

   <xsl:template match="*">
      <ul>
          <xsl:element name="xhtml:UL>
          <xsl:apply-templates/>
          </xsl:element>
      </ul>
   </xsl:template>

Thank you for your assistance.

- Dave


David Carlisle wrote:
It seems that, no matter what the context of an 'xsl:element' element,
no element is output for me.

what do you mean by "no output" you are passing the result tree generated by the stylesheet straight to firefox's rendering engine. As that result tree just consistes of <test> elements which are not valid html, html's error handling will apply which ignores the element and processes its content.

So the end result will be that the output just appears as the character
data, as if ther were no markup, because there is no html markup.

   <xsl:element name="test">
          <xsl:apply-templates/>
       </xsl:element>

can be more simply written as

   <test>
          <xsl:apply-templates/>
   <test>

but I suspect you really want something like

   <div class="{name()}>
          <xsl:apply-templates/>
   <div>

Note that a browser is a hostile place to debug stylesheets as browsers
are designed to go to extrodinary lengths never to report errors, and
because they typically display the result tree as html ratherthan
showing you the result elements, you have to simultaneously check that
your stylesheet is generating teh html you expect and thatthe html you
expect is having the presenattion that you wanted.

It's much simpler to first decide what html you need to get teh display
in teh browser, then get a stylesheet that produces html files of that
form using a command line or editor based xslt system, and only whan its
all working put them together to run in a client side transform. Or some
would argue never do that at all, having generated the html, just serve
the html directly.

David

________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. ________________________________________________________________________


Current Thread
Keywords