This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Is there a way in xsl to point to a node if only apart of its name is known?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]