[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: How to Substitute HTML template with values?

Subject: Re: How to Substitute HTML template with values?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 4 Dec 2003 13:12:51 GMT
xsl substitute

> 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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.