[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Is there a way in xsl to point to a node if only a
Michael wrote: > Is there a way in xsl to point to a node if only a part of its name is > known? >From what I know, there is no wildcard to partially match node names. The only thing close is select="*" which will select all elements. You could try using the XPath name() or local-name() function to return the node name as a string and then test if for what ever you need. > Sample xml 1: > <node1> > <node2> > <node3> > <tableName1.field1>content ...</tableName1.field1> > <tableName1.field2>content ...</tableName1.field2> > <tableName1.field3>content ...</tableName1.field3> > </node3> > </node2> > </node1> eg a template for the above XML sample (Note: This is untested, no guarantees ;-) <xsl:template match="node3"> <xsl:for-each select="*"> <!-- Should select the fieldname after the dot, '.', in the element name <xsl:variable name="fieldname" select="substring-after(local-name(), '.')" /> <xsl:if test="$fieldname = 'foo'"> <!-- Do stuff when element has 'foo' as the fieldname </xsl:if> </xsl:for-each> </xsl:template> HTH, Joshua ------------------------------------------------------------------------------ This message and any attachment is confidential and may be privileged or otherwise protected from disclosure. If you have received it by mistake please let us know by reply and then delete it from your system; you should not copy the message or disclose its contents to anyone. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|