pmartin2000
Programmer
I have been using XML+XSL on and off for few years. I came accross following challenge:
I have following simplified code which is meant to display variable-width images within the table (based on [wantedWidth] from the XML document):
<xml id='myData'>
<rowset>
<row>
<wantedWidth>
200
</wantedWidth>
</row>
<row>
<wantedWidth>
100
</wantedWidth>
</row>
</rowset>
</xml>
<xml id="myDataFormat">
<rowset>
<xsl:for-each select="row" xmlns:xsl=" <row>
<wantedWidth>
<xsl:value-of select="wantedWidth" />
</wantedWidth>
</row>
</xsl:for-each>
</rowset>
</xml>
<table id="myDataTable" datasrc="#myData" border="1">
<thead>
<th>Image:</th>
</thead>
<tr>
<td>
<span datafld="wantedWidth"></span>
<img src="bar.gif" height="10" border=1>
<xsl:attribute name="width">
<xsl:value-of select="wantedWidth"/>
</xsl:attribute>
</img>
</td>
</tr>
</table>
<script>
var xmldso = document.all("myData"
;
var xsltTree = document.all("myDataFormat"
;
xmldso.documentElement.transformNodeToObject(xsltTree.documentElement, xmldso.XMLDocument);
</script>
The problem is that I'm trying to use XSL within datasrc-bound table ... which in itself is not XSL-interpreted. And binding <img> through [datafld] only changes the image's SRC property.
The challenge is to get this working without switching over to just using XSL and dropping the table-bounding.
Any ideas?
Thanks
Pete
I have following simplified code which is meant to display variable-width images within the table (based on [wantedWidth] from the XML document):
<xml id='myData'>
<rowset>
<row>
<wantedWidth>
200
</wantedWidth>
</row>
<row>
<wantedWidth>
100
</wantedWidth>
</row>
</rowset>
</xml>
<xml id="myDataFormat">
<rowset>
<xsl:for-each select="row" xmlns:xsl=" <row>
<wantedWidth>
<xsl:value-of select="wantedWidth" />
</wantedWidth>
</row>
</xsl:for-each>
</rowset>
</xml>
<table id="myDataTable" datasrc="#myData" border="1">
<thead>
<th>Image:</th>
</thead>
<tr>
<td>
<span datafld="wantedWidth"></span>
<img src="bar.gif" height="10" border=1>
<xsl:attribute name="width">
<xsl:value-of select="wantedWidth"/>
</xsl:attribute>
</img>
</td>
</tr>
</table>
<script>
var xmldso = document.all("myData"
var xsltTree = document.all("myDataFormat"
xmldso.documentElement.transformNodeToObject(xsltTree.documentElement, xmldso.XMLDocument);
</script>
The problem is that I'm trying to use XSL within datasrc-bound table ... which in itself is not XSL-interpreted. And binding <img> through [datafld] only changes the image's SRC property.
The challenge is to get this working without switching over to just using XSL and dropping the table-bounding.
Any ideas?
Thanks
Pete