Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Using XSLT to transform XHTML to XHTML (again!)

From: WilliamRayer@-----------.---------.---
To: NULL
Date: 7/7/2008 8:51:00 AM

Hi Martin

That is really neat - & even better it works :) I really appreciate you 
showing me this.

BTW I was also very interested by what you wrote:

> ... adding templates to 
> perform some changes is a fundamental XSLT approach you should try to 
> become familiar with.

I had to get to grips with XSLT about a year ago. Although I'm happy with 
most development tasks (C, C#, SQL etc) I found it very difficult to get to 
grips with transforms. I found this article 
<http://www.xfront.com/rescuing-xslt.html> which was written by soneone with 
the same issues (programming experience but problems getting to grips with 
transforms). His insight (to me) was to treat XSLT as a powerful templating 
language, allowing me to embed the desired HTML output in the XSLT and to 
treat the <xsl...> instructions as special tags that get values from the 
input XML. Anyway sorry to go on but I found XSLT much easier when following 
the 'template' approach. I understand it may be non-ideal and I may need to 
expand my XSLT later on.

Thanks again - Will Rayer


"Martin Honnen" wrote:

> William Rayer wrote:
> 
> > Many thanks - that seems to work fine! But is it possible to do it from 
> > within the context of a single template match on the root node? I am trying 
> > to keep the HTML output in the form:
> > 
> > <xsl:template match="/">
> >   <html>
> >   <head>
> >   <title> <xsl:value-of select="$title"/> </title>
> >   </head>
> >   <body> 
> >   
> >       <!-- XSLT stuff in here -->
> > 
> >   </body>
> >   </html>
> > </xsl:template>
> > 
> > as I find this easier to understand.?
> 
> Well using the identity transformation template and adding templates to 
> perform some changes is a fundamental XSLT approach you should try to 
> become familiar with.
> 
> If you really insist on one template and spelling out the structure 
> again instead of simply copying it then you need
> 
> 
> <xsl:stylesheet version="1.0"
>   xmlns="http://www.w3.org/1999/xhtml"
>   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>   xmlns:xhtml="http://www.w3.org/1999/xhtml"
>    exclude-result-prefixes="xhtml xsl">
> 
>    <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"
>    doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
>  
> doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
> 
> <xsl:param name="title"/>
> 
> <xsl:variable name="h1" select="/xhtml:html/xhtml:body/xhtml:h1[. = 
> $title]"/>
> 
> <xsl:template match="/">
>    <html>
>    <head>
>    <title> <xsl:value-of select="$title"/> </title>
>    </head>
>    <body>
> 
>      <xsl:copy-of select="$h1 | 
> $h1/following-sibling::xhtml:p[generate-id($h1) = 
> generate-id(preceding-sibling::xhtml:h1[1])]"/>
> 
>    </body>
>    </html>
> </xsl:template>
> 
> </xsl:stylesheet>
> 
> 
> 
> 
> -- 
> 
> 	Martin Honnen --- MVP XML
> 	http://JavaScript.FAQTs.com/
> 


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent