Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


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

From: "Brendan Sleight" <bms@---------->
To:
Date: 1/3/2009 8:52:00 PM
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


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent