xslt - Detecting if a node exists? -
i have set of data called <testdata> many nodes inside.
how detect if node exists or not?
i've tried
<xsl:if test="/testdata"> and
<xsl:if test="../testdata"> neither 1 works. i'm sure possible i'm not sure how. :p
for context xml file laid out this
<overall> <body/> <state/> <data/>(the 1 want access </overall> i'm in <body> tag, though i'd access globally. shouldn't /overall/data work?
edit 2: right have index data need use @ anytime when apply templates tags inside of body. how tell, while in body, data exists? does, doesn't. can't control that. :)
try count(.//testdata) > 0.
however if context node textdata , want test whether has somenode child or not write:
<xsl:if test="somenode"> ... </xsl:if> but think that's not want. think should read on different techniques of writing xslt stylesheets (push/pull processing, etc.). when applying these, such expressions not necessary , stylesheets become simplier.
Comments
Post a Comment