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

Re: xml cells transformed in to a 2-d table, some tabl

Subject: Re: xml cells transformed in to a 2-d table, some table cells missing, full table required - constant variables.
From: "Brendan Sleight" <bms@xxxxxxxxxx>
Date: Sat, 3 Jan 2009 20:51:57 +0000
Re:  xml cells transformed in to a 2-d table
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

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.