Jump to content
  • Advertisement
Sign in to follow this  
metrix

[web] XSLT predicate

This topic is 4263 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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!