Xslt defining the third object from current

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ismailc
    New Member
    • Sep 2006
    • 200

    Xslt defining the third object from current

    Hi, I don't know xml.
    The stylesheet identifies all the objects from DB & as it reads through the DB, it checks the next object "for-each", I need to check the third object as well & define within var being "nextNode3"

    I need to specify in the stylesheet to look for the next column – so that I can insert the xml.
    This is the code that checks/defines for current & next, with the next being "nextNode"
    Code:
          <xsl:for-each select="Activity/ObjectGroup[@type='default']/Object">    
          <xsl:sort select="@index" data-type="number" /> 
          <xsl:variable name="index" select="@index" />
          <xsl:variable name="nextNode" select="../Object[ @index > $index ][1]" />
          <xsl:variable name="nextCol" select="$nextNode/@columnNo" /> 
          <xsl:variable name="vis" select="string(Attributes/Attribute[ @name='visible'])" />
          <xsl:variable name="visNextCol" select="string($nextNode/Attributes/Attribute[ @name='visible'])" />
    nextNode specifies the next object & nextCol specifies the next objects column
    Now I just need to specify the 3rd object
    This is what i tried - unsuccessful
    Code:
        <xsl:variable name="nextNode3" select="../Object[ @index > $index ][2]" /> 
        <xsl:variable name="nextCol3" select="$nextNode3/@columnNo" />
        <xsl:variable name="visNextCol3" select="string($nextNode3/Attributes/Attribute[ @name='visible'])" />
    Please Assist, Not too sure

    Regards
    Last edited by jkmyoung; Feb 13 '09, 03:48 PM. Reason: code tags, grammar.
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    Could you post a sample of your source xml? It's hard to see why it's not working, eg your code looks correct from what I can see.

    Comment

    • ismailc
      New Member
      • Sep 2006
      • 200

      #3
      Hi, Thank You for the assist

      I'm only editing an existing xslt file and have no experience in xml.
      The current file allows for 2 objects to be next to one another on one row when object2 column no = 2. I want to add a third object to the row when column no = 3, but i can't determine the 3rd object, on one row = object1, object2, object3

      This is the code of the original xslt file, code in bold is what I added.

      Code:
      <?xml version="1.0"?>
      
      <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:asp="remove" xmlns:igchart="remove" xmlns:igsch="remove" xmlns:igtxt="remove">
      <xsl:output omit-xml-declaration = "yes" />
      <xsl:template match="/">
      <xsl:for-each select="Activity/ObjectGroup[@type='default']/Object"> 
      <xsl:sort select="@index" data-type="number" /> 
      <xsl:variable name="index" select="@index" />
      <xsl:variable name="nextNode" select="../Object[ @index > $index ][1]" />
      <xsl:variable name="nextCol" select="$nextNode/@columnNo" />
      
      [B]<xsl:variable name="nextNode3" select="../Object[ @index > $index ][3]" />
      <xsl:variable name="nextCol3" select="$nextNode3/@columnNo" />
      <xsl:variable name="visNextCol3" select="string($nextNode3/Attributes/Attribute[ @name='visible'])" />[/B]
      
      <xsl:variable name="vis" select="string(Attributes/Attribute[ @name='visible'])" />
      <xsl:variable name="visNextCol" select="string($nextNode/Attributes/Attribute[ @name='visible'])" />
      
      <xsl:if test="($vis != 'False') or ($nextCol = '2' and ($vis != 'False' or $visNextCol != 'False')) [B]or ($nextCol3 = '3')">[/B]
      
      <xsl:if test="(@columnNo != '2')">
        <tr>
             <xsl:if test="($nextCol = '2') and $visNextCol != 'False'">
                <tr>
             </xsl:if>
      [B]      <xsl:if test="($nextCol3 = '3') and $visNextCol3 != 'False'">
               <tr>
             </xsl:if>[/B]
      
      </xsl:if>
      </xsl:if>
      It gives me an error, the third object is already used by another control

      Please help, Regards
      Last edited by Dormilich; Feb 16 '09, 05:15 PM. Reason: added [code] tags

      Comment

      Working...