Anyone here good with XSLT?
Mike
el.fontanero-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org
Wed Aug 4 23:40:28 UTC 2010
Slight modifications:
I'm using xsltproc, which apparently only understands XSLT 1.0, so at
the head of the stylesheet:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
When I invoke xsltproc with "--html", it complains bitterly. So I turn
the input HTML into XHTML:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<p>Hello World</p>
</head>
<body>
<p>Goodbye World</p>
</body>
</html>
This ain't quite right, but is getting there. Turns out nothing was
processing <html>
-----------------------------------------------------------------
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:html="http://www.w3.org/1999/xhtml"
version="1.0">
<xsl:output method="html"/>
<xsl:template match="/">
<xsl:message>Starting root</xsl:message>
<xsl:apply-templates />
<xsl:message>Ending root</xsl:message>
</xsl:template>
<!-- Need this to process html -->
<xsl:template match="html:html">
<xsl:message>Doing html</xsl:message>
<!-- Need this to continue processing children of html -->
<xsl:apply-templates />
</xsl:template>
<xsl:template match="html:head">
<xsl:message>Doing head</xsl:message>
</xsl:template>
<xsl:template match="html:body">
<xsl:message>body</xsl:message>
</xsl:template>
<!-- This is handy: from the docbook xsl stylesheets:
For example, try this without the template for "html:html"
-->
<xsl:template match="*">
<xsl:message>
<xsl:text>Element </xsl:text>
<xsl:value-of select="local-name(.)"/>
<xsl:text> in namespace '</xsl:text>
<xsl:value-of select="namespace-uri(.)"/>
<xsl:text>' encountered</xsl:text>
<xsl:if test="parent::*">
<xsl:text> in </xsl:text>
<xsl:value-of select="name(parent::*)"/>
</xsl:if>
<xsl:text>, but no template matches.</xsl:text>
</xsl:message>
</xsl:template>
</xsl:stylesheet>
--------------------------------------
$ xsltproc -o test-out.html test.xsl test.html
Doing html
Doing head
body
---------------------------------------------
Hope this generates further questions of a different nature...
Cheers,
Mike
On Wed, Aug 4, 2010 at 6:54 PM, Evan Leibovitch <evan-ieNeDk6JonTYtjvyW6yDsg at public.gmane.org> wrote:
> OK, here goes. I have a stylesheet:
>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="2.0">
> <xsl:output method="html"/>
>
> <xsl:template match="/">
> <xsl:message>Starting root</xsl:message>
> <xsl:apply-templates />
> <xsl:message>Ending root</xsl:message>
> </xsl:template>
>
> <xsl:template match="head">
> <xsl:message>Doing head</xsl:message>
> </xsl:template>
>
> <xsl:template match="body">
> <xsl:message>body</xsl:message>
> </xsl:template>
>
> </xsl:stylesheet>
>
>
> and an input file:
>
> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
> <head>
> <p>Hello World</p>
> </head>
> <body>
> <p>Goodbye World</p>
> </body>
> </html>
>
> When I process this I would expect to see the messages from the "head" and
> "body" templates be executed (and the message showing). But they don't. Any
> idea what I'm doing wrong?
>
> Thanks!
>
> - Evan
>
>
--
The Toronto Linux Users Group. Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists
More information about the Legacy
mailing list