Subject: Re: [xsl] How to Substitute HTML template with values? From: David Carlisle <davidc@xxxxxxxxx> Date: Thu, 4 Dec 2003 13:12:51 GMT |
> href="D:\Test\XML\subst.xhtml"?> URIs don't start with D: (unless you know of a competing protocol to http:-) and don't use \ href="file:///D:/Test/XML/subst.xhtml"?> sometimes it will work, but if it does that is a non conforming application being "kind" and at some point you'll come up against a conforming application that will fail (See Ken Holman's message from a minute ago) Again, my point is that I want to be able to build and design the page as a regular html (xhtml) doc, using standard tools. Hm, OK. personally I wouldn't use a tool that didn't show me exactly the markup that it was inserting (I don't trust them enough:-) but if that's what you want I'd do a two step process (as xslt doesn't have dynamic xpath evaluation) 1 write your template (no need for xsl:version in the html element this time, and use the same {} syntax in element content as well as attributes. <html> <head><title>My Template</title></head> <body> <br />Name <input type="text" value="{/mapping/NAME}" size="15"/> <br />Address <input type="text" value="{/mapping/ADDR}" size="15"/> <table> <thead> <tr> <th>One</th> <th>Two</th> </tr> </thead> <tbody> <xsl:for-each select="/mapping/MYTABLE/ROW"> <tr> <td>{/some/path/C1}</td> <td>{/some/path/C2}</td> </tr> </xsl:for-each> </tbody> </table> </body> </html> 2) run stylesheet a over your template <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="*"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates/> </xsl:copy> </xsl:template> <xsl:template match="/*"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:attribute name="xsl:version">1.0</xsl:version> <xsl:apply-templates/> </xsl:copy> </xsl:template> <xsl:template match="*[starts-with(.,'{')]"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:element name="xsl:value-of"> <xsl:attribute name="select"> <xsl:value-of select="substring-before(substring-after(.,'{'),'}')"/> </xsl:attribute> </xsl:element> </xsl:copy> </xsl:template> <xsl:stylesheet> with a bit of luck that will generate for you a stylesheet like the one you posted, which you then 3) run this new stylesheet over your xml file. David -- http://www.dcarlisle.demon.co.uk/matthew ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] How to Substitute HTML te, Amir Yiron | Thread | [xsl] \, David Tolpin |
[xsl] How to package XSLT/XML files, santony | Date | [xsl] \, David Tolpin |
Month |