Copied to clipboard

Flag this post as spam?

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


  • julius 107 posts 289 karma points
    Sep 03, 2011 @ 21:25
    julius
    0

    XSLT query: select nodes from a certain doctype under a certain root node

    Hey folks, it's me again :-)

    I am trying to implement a method in .NET that allows me to get nodes from a certain type that reside under a certain other node. The method signature is this

    I want to create an XPath query that allows me to select anything under "rootNode" that is a node of one of the document types in restrictDocTypes.

    The main question here is: how do I get the supplied rootNode in my xPath query? Basically I need the XSLT equivalent of "$rootNode/descendant-or-self::*..... etc". Is it possible to somehow convert the supplied .NET rootNode to a variable in my XSLT query?

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Sep 03, 2011 @ 22:59
    Tom Fulton
    1

    I suppose you could do something like:

    string xPathQuery = "/root/descendant::* [@id = '" + rootNode.Id + "']/";

    You could also probably do something like rootNode.Children.Where(n => n.nodeTypeAlias == 'whatever')

    Also if you haven't already, look into uQuery and their extension methods, there are some that should help you out ie rootNode.GetDescendantNodes

  • julius 107 posts 289 karma points
    Sep 04, 2011 @ 12:59
    julius
    0

    Hey Tom,

    This is what I came up with and it works:

    "/root/descendant::* [@id = 1100]/descendant::* [@isDoc and @nodeType = 1067 or @nodeType = 1022]"

     

    First the supplied root node is selected and then descendants of the root node with nodeTypes 1067 or 1022.

     

    Thanks.

Please Sign in or register to post replies

Write your reply to:

Draft