XPath craziness
This is an open discussion with 5 replies, filed under XSLT.
Search
Try <xsl:template match="/data/schedule/*" mode="events">
I’m trying to match all data source schedule*, /data/schedule, /data/schedule-etc, /data/schedule-etc-etc
then you’ll have to use something like
<xsl:template match="/data/*[substring(name(),1,8) = 'schedule']" mode="events">
Needless to say, nobody will understand what you did there so I suggest you use something like
<xsl:template match="/data/schedule | /data/schedule-etc | /data/schedule-etc-etc" mode="events">
instead.
Or something equally complex:
match="/data/*[starts-with(name(),'schedule')]"
I’d go with phoque’s second suggestion. Matching a dynamic node name is going to be slightly more processor-intensive, and it feels like it ought to be good practice to code the exact nodes that you are matching against.
As a fix to get it working, I did what phoque suggested. But I imagine you’re right, I imagine it will be faster, especially on a shared host.
Thanks guys.
Create an account or sign in to comment.
Recently, one of my websites hosting providers switched systems, and everything except one thing compiled/worked fine for XSLT.
The statement in question is
That throws an error that’s corrected once I take out the asterisk. While I can manually type in all of the data sources it could match, it’d be tedious. I’m inclined to believe the problem was in the upgrade somewhere, but I’m fairly sure I use the asterisk in many other places.
Any ideas?