Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Aaron 7 posts 27 karma points
    Jul 04, 2011 @ 00:46
    Aaron
    0

    xslt child nodes only selectable using child::* w/ XPathNodeIterator?

    Hi guys,

    New to Umbraco, loving it so far, but I've hit a strange issue.

    set up an xslt extension and variable $Individuals to query from a remote business layer

    <xsl:variable name="Individuals" select="Elements.Extensions:Query('select * from Individual')"/>

    XML returns OK (tuncated for brevity):

    <IndividualObjects><IndividualObject><ind_first_name>Aaron</ind_first_name></IndividualObject></IndividualObjects>

    I want to select the IndividualObjects. My instinct would be to for-each through $Individuals/IndividualObject, but that doesn't seemt to work. Here's the tests:

     

      test1<br />
      <xsl:for-each select="$Individuals">
        This came from the $individuals selector:<xsl:value-of select ="name(.)"/>  
      </xsl:for-each>
      test2<br />
      <xsl:for-each select="$Individuals/child::*">
        This came from the child:: selector: <xsl:value-of select ="name(.)"/>
      </xsl:for-each>
      
      test3<br />
      <xsl:for-each select="$Individuals/IndividualObject">
        This came from the $Individuals/IndividualObject selector:<xsl:value-of select ="name(.)"/>  
      </xsl:for-each>
     
      test4<br />
      <xsl:for-each select="$Individuals//IndividualObject">
        This came from the $Individuals//IndividualObject selector:<xsl:value-of select ="name(.)"/>  
      </xsl:for-each>

     

    The output is as follows:

    test1
    This came from the $individuals selector:IndividualObjects

    test2
    This came from the child:: selector: IndividualObject

    test3
    test4

    So the xml is coming back correctly, and the nodes are properly parsed. But they're unselectable? I'm baffled. Do you just always use child:: and then compare the element name? I'm using XPathNodeIterator -- should I be using something else?

    I must be missing something basic - any input would appreciated.

    Thanks, Aaron

     

     

     

Please Sign in or register to post replies

Write your reply to:

Draft