Sign in to follow this  

[web] XSLT predicate

This topic is 4071 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys, Say I have a node from an xml file:
<!-- XML NODE -->
<nodeparent>
   <node attr=1>
      <child1>foo</child1>
      <child2>bar</child2>
   </node>
   <node attr=2>
      <child1>hu</child1>
      <child2>ha</child2>
   </node>
</nodeparent>

and then i have some parameters in my xsl file: <xsl:param name="attrlvl" /> <xsl:param name="str" /> These paremters are set dynamically via some javascript. I'd like to be able to query a set of node's such that the set in question has @attr equal to attrlvl and the value of child1 (a string) contains str as a substring. <xsl:apply-templates select="nodeparent[$attrlvl=@attr and contains(child1,str)]" /> The problem with this is that what if I want to extract every node? That is, all nodes of any attr and child1 or any value. Is there a mechanism by which I can do this without doing a bunch of messy <xsl:choose>/<xsl:when> code? Another question: Since I am setting my <xsl:param> 's dynamically, I thought it would be useful if I had a parameter which contained my predicate. That way I could build my query string in javascript and then pass it to the XSLT processor. And then: <xsl:apply_templates select="nodeparent[$filterstring]"/> However, it doesnt seem to like it, and I dont know why. Any idea's? Thanks, metrix

Share this post


Link to post
Share on other sites

This topic is 4071 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this