Subject:descriptive? node Author:Paul Medina Date:23 Feb 2007 09:48 PM
Hi all,
I've been struggling with an XSLT project. I've got the basics down but I'm having trouble with the following XML to HTML conversion.
Sample XML
<document>
<item>
<pardef id="1" leftmargin="1in"/>
<par def="1">
<run>
<font style="italic" color="blue" size="8pt"/>
some text 1
</run>
</par>
<par>
<run>
<font weight="bold" size="8pt"/>
some text 2
</run>
</par>
<pardef id="2" align="center"/>
<par def="2">
<run>
<font size="8pt"/>
some text 3
</run>
</par>
<par def="1">
<run>
<font size="8pt" color="red"/>
some text 4
</run>
</par>
</item>
</document>
Each pardef node sets up a definition for each par node that has the same def attribute value as the matching pardef id attribute value and any subsequent par node without a def attribute up until either another pardef node or a par def="x" node is encountered.
So in the above xml the par def="2" node should be centered when converted to HTML then the following par def="1" node should have a left margin of "1in" as specified in the pardef id="1" descriptive node.
I tried capturing the id of a pardef node in a variable and then comparing each par that I came across. I would apply the attributes to each par node up until either the def id attribute changed or another pardef node was encountered . This would seem to work but unforutenately xsl:variable can't be re-assigned. The stylesheet I tried is below. It should produce the following HTML:
<span style="margin-left: 10px; font-size:8pt; font-style:italic; color:blue;">
some text 1
</span><p/>
<span style="margin-left: 10px; font-size:8pt; font-weight:bold;">
some text 2
</span><p/>
<span style="text-align: center; font-size:8pt;">
some text 3
</span><p/>
<span style="margin-left: 10px font-size:8pt;">
some text 4
</span>
I'd appreciate it if anyone can provide some insight.
Subject:descriptive? node Author:(Deleted User) Date:26 Feb 2007 08:41 AM
Hi Paul,
this is a generic XSLT question, but this is a support forum for Stylus Studio; you can get better answers on a XSLT mailing list like the one run by Mulberry Tech.