473,395 Members | 1,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

XML matches

Dormilich
8,658 Expert Mod 8TB
what a pun........

well, back to my question. can anyone confirm that the match attribute of <xsl:template> chokes on XPaths with conditions, like
<xsl:template match="node()[@attr = 'value']">
it's doing that every time I try this (XSLT 1.0). has anyone found an explanation for this?

regards

PS: If you wonder, I have already figured out a workaround for me
Nov 23 '08 #1
3 3083
jkmyoung
2,057 Expert 2GB
? Which processor are you using?
Are you sure the node isn't getting picked up by some other less-generic template?
Since you're looking for a element node, I suggest using
"*[@attr='value']"
Nov 26 '08 #2
Dormilich
8,658 Expert Mod 8TB
processors:
- for a quick test I use FF's transformiix or the "get XSL result" addon
- developer server is Mac 10.5.5 / apache 2.2.10 / libxml 2.7.2 / libxslt 1.1.24 / php 5.2.6
- production server is linux / apache / php 5.2.6 / libxml 2.6.31 / libxslt 1.1.21 (-> libxml 2.6.28)

node() was just a placeholder, I have the element's xpath there.

this problem arises if I want to pick up one single element only, like
Expand|Select|Wrap|Line Numbers
  1. // xml headers
  2. <xsl:stylesheet [...]>
  3. // xsl processing options
  4.  
  5. <xsl:template match="//element[@attr = 'value']">
  6. // this is the only template
  7. // do frenzy stuff with the node
  8. </xsl:template>
  9.  
  10. </xsl:stylesheet>
FF gives an "invalid xpath" error

Dormi
Nov 27 '08 #3
jkmyoung
2,057 Expert 2GB
Still having problems recreating it. Using xml:
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"?>
  2. <?xml-stylesheet type="text/xsl" href="test.xsl"?>
  3. <!-- this is a test document -->
  4. <document>
  5.     <!-- test comment -->
  6.     <x name="value">x</x>
  7.     <y name="value">y</y>
  8.     <z name="value">z</z>
  9.     <abc>
  10.         <def>def</def>
  11.     </abc>
  12.     <z noname="z">p</z>
  13.     <z name="q">q</z>
  14. </document>
  15.  
xsl:
Expand|Select|Wrap|Line Numbers
  1. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  2.     <!-- set the output properties -->
  3.     <xsl:output method="html"/>
  4.     <xsl:template match="/*">
  5.         <html>
  6.             <head/>
  7.             <body>
  8.                 <xsl:apply-templates/>
  9.             </body>
  10.         </html>
  11.     </xsl:template>
  12.     <xsl:template match="*">
  13.         <div>
  14.     <xsl:value-of select="'text'"/>
  15.     <xsl:apply-templates/>
  16.         </div>
  17.     </xsl:template>
  18.     <xsl:template match="//z[@name='value']">
  19.     <div>
  20.     <xsl:value-of select="'found element'"/>
  21.     <xsl:apply-templates/>
  22.     </div>
  23.     </xsl:template>
  24. </xsl:stylesheet>
  25.  
Does this produce the error on your side?
Dec 1 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: André Søreng | last post by:
With the re/sre module included with Python 2.4: pattern = "(?P<id1>avi)|(?P<id2>avi|mp3)" string2match = "some string with avi in it" matches = re.finditer(pattern, string2match) .......
1
by: weston | last post by:
Has anyone ever encountered trouble with regular expressions not capturing matches specified by parentheses? I seem to have a weird situation where a regular expression is matching the String I'm...
1
by: Steve Taylor | last post by:
I'm experiencing bad performance with certain kinds of match queries. Using a custom XPathNavigator that wraps the usual navigator I can see that many more node visits are performed than should be...
4
by: Chris Beach | last post by:
Hi there, I'm attempting to extract a number from a string, and I'm using the following code: Regex prRegexp = new Regex( @"Rank_1:\d+:(\d+)" ); MatchCollection matches = prRegexp.Matches(...
5
by: Mystilleef | last post by:
Hello, Is there a simple flag to set to allow overlapping matches for the findall() regular expression method? In other words, if a string contains five occurrences of the string pattern "cat",...
5
by: Chris Lasher | last post by:
Hey guys and gals, This is a followup of my "Counting all permutations of a substring" thread (see...
26
by: John Salerno | last post by:
I probably should find an RE group to post to, but my news server at work doesn't seem to have one, so I apologize. But this is in Python anyway :) So my question is, how can find all...
11
by: abcd | last post by:
how can i determine if a given character sequence matches my regex, completely? in java for example I can do, Pattern.compile(regex).matcher(input).matches() this returns True/False whether...
5
by: RolfK | last post by:
Dear ALL, I'm writing some first examples to get a better understanding of XSLT/ XPATH2.0. Please excute this code, any xml input is OK. I'm using saxon. The example runs perfect with ALTOVA,...
4
by: =?Utf-8?B?a2FydXpv?= | last post by:
Hi, I cannot guess, why some XPath expressions in my code returns false and some even errors, while the others returne true as I expected. I'am workin with VS 2008 Express Edition. Dim xEl As...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.