xsl-list
[Top] [All Lists]

Re: [xsl] xml cells transformed in to a 2-d table, some table cells missing, full table required - constant variables.

2009-01-03 15:52:22
Hi Michael,

Thank-you for both of your responses very informative.

Now for some reason you have chosen to use XSLT 1.0 rather than XSLT 2.0.
That makes the problem no fun at all. If you really have to use XSLT 1.0,

Unfortunately I can not find a python library to support XSLT 2.0. The
library I am using only supports 1.0. I have written a large chunk of
code already so I have to stay with 1.0 only for now.

    <xsl:variable name="ig" select="$doc//intergreen[from = $x and to =
$y]"/>

When using XSLT 1.0 I got various error messages with the above syntax.
XPath error : Invalid expression
if (exists($ig)) then $ig/length else 0
                 ^

Just using the exists statement I got:-
xmlXPathCompOpEval: function exists not found

However I managed to work around this by looking at the string-length.
Working solution:-

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:template match="/">
<tt>
<i>&#160;</i>
<xsl:for-each select="//traffic_signals/site/phases/phase">
 <i>&#160;<xsl:value-of select="letter" />&#160;</i>
</xsl:for-each>
 <i>&#160;
</i>
<xsl:for-each select="//traffic_signals/site/phases/phase">
 <xsl:variable name="row" select="letter"/>
 <i><xsl:value-of select="letter" /></i>
 <xsl:for-each select="//traffic_signals/site/phases/phase">
    <xsl:variable name="col" select="letter"/>
    <xsl:variable name="ig"
select="//traffic_signals/site/intergreens/intergreen[from=$row and
to=$col]/length"/>
    <xsl:if test="string-length($ig) &gt; 1" >
       <b><xsl:value-of select="$ig" />&#160;</b>
    </xsl:if>
    <xsl:if test="string-length($ig) &gt; 0" >
       <b>&#160;<xsl:value-of select="$ig" />&#160;</b>
    </xsl:if>
    <xsl:if test="string-length($ig) &lt; 1" >
       <xsl:if test="$row = $col" >
         <b>&#160;X&#160;</b>
       </xsl:if>
       <xsl:if test="$row != $col" >
         <b>&#160;-&#160;</b>
       </xsl:if>
    </xsl:if>
 </xsl:for-each>
 <i>&#160;
</i>
</xsl:for-each>
</tt>
</xsl:template>
</xsl:stylesheet>


Thanks for the help and feedback.

Regards,
Brendan M. Sleight

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--