Copied to clipboard

Flag this post as spam?

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


  • Nigel Wilson 945 posts 2077 karma points
    Jul 01, 2010 @ 04:09
    Nigel Wilson
    0

    Find Matching Nodes Using a Data Value

    I am modifying the XSLT search to read / filter an external XML file. 

    I have structured the data to mirror the standard XML data structure within UMBRACO - an excerpt is as follows:

    ...
    <node id="1513" parentID="-1" path="-1" level="1">
      <data alias="Name">Andrew Antelope</data>
      <data alias="FirstName">Andrew</data>
      <data alias="Surname">Antelope</data>
      <data alias="Employer">Andrews Pies Limited</data>
      <data alias="Email">[email protected]</data>
      <data alias="JobTitle">Manager</data>
      <data alias="Roles">1249</data>
      <data alias="PrimaryBusinessCategory">Pies</data>
    </node>
    <node id="7700" parentID="-1" path="-1" level="1">
      <data alias="Name">Bruce Bricks</data>
      <data alias="FirstName">Bruce</data>
      <data alias="Surname">Bricks</data>
      <data alias="Employer">Bruce Company Limited</data>
      <data alias="Email">[email protected]</data>
      <data alias="JobTitle">Foodservice Sales Manager</data>
      <data alias="Roles" />
      <data alias="PrimaryBusinessCategory" />
    </node>
    ...

    The user is able to submit an Employer name as part of their search criteria.

    So I am then trying to filter the node set based on the "Employer" data field. 

    The following is what I have attempted but it isn't working:

    $possibleNodes is the node set
    $companyName is the search input string

    <xsl:for-each select="$possibleNodes[./data[@alias='Employer'][contains(text(),$companyName)]]">

    Please, please show me the error of my ways !

    Thanks

    Nigel

  • Paul Blair 466 posts 731 karma points
    Jul 01, 2010 @ 07:15
    Paul Blair
    1

    try :

    <xsl:for-each select="$possibleNodes[./data[@alias='Employer' and contains(text(),$companyName)]]">

    (i.e. use an AND join.  I haven't tested - if doesn't work let us know :)

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jul 01, 2010 @ 09:10
    Dirk De Grave
    1

    Or maybe it's even more simple if using

    <xsl:for-each select="$possibleNodes[contains(./data[@alias='Employer',$companyName)]">

    (Haven't tested that though..)

     

    Cheers,

    /Dirk

  • Nigel Wilson 945 posts 2077 karma points
    Jul 01, 2010 @ 19:36
    Nigel Wilson
    0

    Hi Paul and Dirk

    Do they give out the numpty of the week award in Umbraco Forum land ? I definitely deserve it!

    There was no issue with this particular piece code, however am using Dirk's suggestion.

    I discovered that the problem was immediately after this piece of code - the resulting output is a string of IDs and I wasn't cross referencing that to the node set - oops!

    So thanks for your input - sometimes you get a bit myopic after going round in circles trying to fix something - a nights sleep and a fresh perspective definitely helps.

    Regards

    Nigel

  • Paul Blair 466 posts 731 karma points
    Jul 01, 2010 @ 23:35
    Paul Blair
    0

    hey Nigel, sometimes a nights sleep is the best debugger :)

  • Paul Blair 466 posts 731 karma points
    Jul 01, 2010 @ 23:35
    Paul Blair
    0

    hey Nigel, sometimes a nights sleep is the best debugger :)

Please Sign in or register to post replies

Write your reply to:

Draft