View Single Post
  #4 (permalink)  
Old September 5th, 2006, 07:21 AM
pvasudevan pvasudevan is offline
Authorized User
 
Join Date: Nov 2003
Location: , , .
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Default

So I tried formatting the template's elements to include like:

  <xsl:template name="tValues">
    <xsl:param name="value" select="''"/>
    <xsl:analyze-string select="$value" regex=",|\t">
      <xsl:matching-substring/>
      <xsl:non-matching-substring>
      <xsl:variable name="p" select="(position()+1) div 2"/>
        <xsl:element name="{$entry[$p]}">
    <xsl:choose>
          <xsl:when test="{$p}=5">
        <xsl:value-of select="following-sibling::{$value[4]}"/>
      </xsl:when>
    <xsl:otherwise>
        <xsl:value-of select="."/>
    </xsl:otherwise>
    </xsl:choose>
        </xsl:element>
      </xsl:non-matching-substring>
    </xsl:analyze-string>
  </xsl:template>

but I guess, am making some syntatical errors. this is primarily because am new to XSLT programming.

First of all: writing a statement like this <xsl:when test="{$p}=5">
where the variable value is being tested itself is erroring out. Also I wonder why there is no "else" part to the <xsl:if> element.

Folloiwng-sibling, i guess works more w.r.t data already formatted in xml format and then we are trying to read. but in my case, the data i'm trying to read is in csv format from a text file, so in wonder if following-sibling would work or not. i also wonder if writing a syntax like this <xsl:value-of select=".."/> after a valid "if" condition would work.

primarily, i first need to understand how to write a valid "if" statement, then how i could write "value-of select" correctly to read the next context element.

Any tips I could get, that'll be gr8.

Thanks,
Praveen

Reply With Quote