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

trouble re-rendering XHTML using xsl

Subject: trouble re-rendering XHTML using xsl
From: "Bruce Kimpel" <bruce_kimpel@xxxxxxxxxxx>
Date: Thu, 14 Feb 2002 11:38:09 -0700
xsl attribute readonly
Hello again,

This is part two of the trouble I am having with xsl transformations, and is a continuation of my previous post:
"trouble merging an XHTML and XML document into one"


The reason I wish to merge the two into one is actually so I can perform another transformation on the new merged document.

The setup (assuming the previous merge worked):
I now have some raw xml in memory...
---------------------------------------------------------------------
<NewPage>
<html xml...>
    <body>
         Bruce
         <br/>
         <input id="btnDoSomething" type="button" value="Do Something"/>
    </body>
</html>
<RenderingControl>
    <ElementToBeChanged>
         <Name>btnDoSomething</Name>
         <RenderAs>Read-Only</RenderAs>
    </ElementToBeChanged>
</RenderingControl>
</NewPage>

The xsl transformation I wish to perform on the raw XML...
---------------------------------------------------------------------
ReRender.xsl
---------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>


<xsl:template match="/">
<xsl:for-each select="RenderingControl">
<xsl:variable name="CurrentElement" select="Name"/>
<xsl:for-each select="html">
<xsl:choose>
<xsl:when test=".[@id=$CurrentElement]">
<xsl:variable name="RenderElementAs"><xsl:value-of select="RenderingControl/ElementToBeChanged/{@id}/RenderAs"/></xsl:variable>
<xsl:choose>
<xsl:when test="button">
<xsl:if test="RenderElementAs='HIDDEN'">
<xsl:attribute name="visibility">hidden</xsl:attribute>
</xsl:if>
<xsl:if test="RenderElementAs='READONLY'">
<xsl:attribute name="read-only">true</xsl:attribute>
</xsl:if>
<xsl:if test="RenderElementAs='NORMAL'">
<xsl:attribute name="visibility">visible</xsl:attribute>
<xsl:attribute name="read-only">false</xsl:attribute>
</xsl:if>
</xsl:when>
<!-- other HTML elements here -->
<xsl:otherwise>
<!-- do nothing - leave the original HTML untouched -->
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$CurrentElement"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:for-each>
</xsl:template>


</xsl:stylesheet>

What I am hoping to achieve is any form element in <HTML ...> tree that has a corresponding entry in the <RenderingControl> tree will convert its attributes to the new one (re-rendering essentially),
and any part of the html that doesn't correspond to a RenderingControl should just be copied 'as is'.


The resulting HTML...
<html xml...>
<body>
Bruce
<br/>
<input id="btnDoSomething" READ-ONLY="Read-Only" type="button" value="Do Something"/>
</body>
</html>


SaberBruce

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.


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.