We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,337 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Regular Expressions in match attribute

Hello.

I just want to know if it's possible to use regular expressions in the match attribute of the template element.
For example , suppose i have the follow xml document:
<greeting>
<aaa>Hello</aaa>
<bbb>Good</bbb>
<ccc>Excellent</ccc>
<dddline>Line</dddline>
</greeting>

Now the xslt to transform the above document:
<xsl:stylesheet>

<xsl:template match="/">
<xsl:apply-templates select="*"/>
</xsl:template>

<xsl:template match="matches(node-name(*),'line')">
<xsl:value-of select="."/>
</xsl:template>
</xsl:styleshhet>

When i try to use the syntax (matches(node-name(*),'line$')) in the match attribute of the template element , it retrieves a error message.Can i use regular expressions in the match attribute ?

Thanks very much

2
Contributors
1
Reply
15 Hours
Discussion Span
2 Years Ago
Last Updated
2
Views
Pedro Costa
Newbie Poster
1 post since Jun 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

If you're using XSLT 2.0, there is full support for Regular Expressions. However in 1.0, its not as freely available.

What's wrong with this?

<xsl:template match="*[contains(local-name(),'line')]">
	<xsl:element name="New">
		<xsl:value-of select="." />
	</xsl:element>
</xsl:template>
iceandrews
Junior Poster
185 posts since May 2010
Reputation Points: 10
Solved Threads: 30
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.5348 seconds using 2.65MB