473,663 Members | 2,933 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XML matches

Dormilich
8,658 Recognized Expert Moderator Expert
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 3087
jkmyoung
2,057 Recognized Expert Top Contributor
? 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 Recognized Expert Moderator Expert
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 Recognized Expert Top Contributor
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
3263
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) .... matches.groupdict() {'id2': None, 'id1': 'avi'} Which was expected since overlapping matches are ignored.
1
2132
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 running it against, but none of the parenthized expressions are coming back in the array. I'm basically trying to pull a topic out of a bulletin board page. So I'll run: var bodystr = new
1
2657
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 required. My document looks something like this: <a> <b> <c/> </b> <b/>
4
1602
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( responseText.ToString() );
5
8476
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", calling findall on the string returns a list containing five "cat" strings. Is it possible for findall() to just return one "cat" string? Thanks
5
1443
by: Chris Lasher | last post by:
Hey guys and gals, This is a followup of my "Counting all permutations of a substring" thread (see http://groups.google.com/group/comp.lang.python/browse_thread/thread/60ebeb7ae381b0a9/7657235b3fd3966f#7657235b3fd3966f in Google Groups) I'm still having a difficult time figuring out the intricacies of regular expressions and consecutive matches. Here's a brief example: In : import re
26
2375
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 occurrences of a pattern in a string, including overlapping matches? I figure it has something to do with look-ahead and look-behind, but I've only gotten this far: import re string = 'abababababababab'
11
1427
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 or not input matches the regex completely. is there a matches in python?
5
4534
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, but fails with SAXON. Please refere to line with element <matcheswhich is quite close to the error.
4
3157
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 XElement = <root><child1><child2/></child1></root> Dim nav As XPathNavigator = xEl.CreateNavigator nav.MoveToRoot()
0
8437
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8348
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8861
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8778
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7375
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5660
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4351
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2764
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1759
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.