473,799 Members | 3,197 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Patterns in XSL - once again

Hi,

In XSLT1.0, are these two match expressions not supposed to match the
same nodes:

child::foo

and

foo

?

As I can read the grammar for match expression in the spec, child:; is
implied when there is no / or // at the beginning, and no exlpicit axis.

-- but my xsltproc behaves differently with and without the child:: !

Where is the bug.. ?

Soren
Jul 20 '05 #1
5 1316
Soren Kuula <do******@daimi .au.dk> writes:
Hi,

In XSLT1.0, are these two match expressions not supposed to match the
same nodes:

child::foo

and

foo

?

As I can read the grammar for match expression in the spec, child:; is
implied when there is no / or // at the beginning, and no exlpicit axis.

-- but my xsltproc behaves differently with and without the child:: !

Where is the bug.. ?


somewhere that you haven't shown us. What different behaviour do you
see?

child::foo and foo are equivalent in XPath expressions an in XSLT match
patterns.
David
Jul 20 '05 #2
Hi,

All right I neglected the example. Here is one:

Input doc:
[dongfang@granad a xslt-examples]$ cat position-fun.xml
<?xml version='1.0'?>
<warehouse>
<item name="foo">
<country>Argent ina</country>
</item>
<item name="bar">
<country>Brazil </country>
</item>
<item name="baz">
<country>Chin a</country>
</item>

1st stylesheet:
[dongfang@granad a xslt-examples]$ cat position-fun21.xsl
<?xml version='1.0'?>
<xsl:styleshe et xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml" indent="yes"/>

<xsl:template match='warehous e'>
<position-experiment>
<first-try>
<xsl:apply-templates select='item/country | text()'/>
</first-try>
</position-experiment>
</xsl:template>

<xsl:template match='country[1]'>
<first-country>
(with "first", we mean: <xsl:value-of select="positio n()"/>)
<xsl:copy-of select='.'/>
</first-country>
</xsl:template>

<xsl:template name="notfirst" match='country' >
<xsl:copy-of select='.'/>
</xsl:template>
</xsl:stylesheet>

Output:
[dongfang@granad a xslt-examples]$ xsltproc position-fun21.xsl
position-fun.xml
<?xml version="1.0"?>
<position-experiment>
<first-try>
<first-country>
(with "first", we mean: 2)
<country>Argent ina</country></first-country>
<first-country>
(with "first", we mean: 4)
<country>Brazil </country></first-country>
<first-country>
(with "first", we mean: 6)
<country>Chin a</country></first-country>
</first-try>
</position-experiment>
2nd stylesheet: Only difference is addition of child:: in match exp

[dongfang@granad a xslt-examples]$ cat position-fun22.xsl
<?xml version='1.0'?>
<xsl:styleshe et xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml" indent="yes"/>

<xsl:template match='warehous e'>
<position-experiment>
<first-try>
<xsl:apply-templates select='item/country | text()'/>
</first-try>
</position-experiment>
</xsl:template>

<xsl:template match='child::c ountry[1]'>
<first-country>
(with "first", we mean: <xsl:value-of select="positio n()"/>)
<xsl:copy-of select='.'/>
</first-country>
</xsl:template>

<xsl:template name="notfirst" match='country' >
<xsl:copy-of select='.'/>
</xsl:template>
</xsl:stylesheet>

Output:

[dongfang@granad a xslt-examples]$ xsltproc position-fun22.xsl
position-fun.xml
<?xml version="1.0"?>
<position-experiment>
<first-try>
<country>Argent ina</country>
<country>Brazil </country>
<country>Chin a</country>
</first-try>
</position-experiment>
[dongfang@granad a xslt-examples]$

Some difference there.

As I get it, they should have been identical??

Soren

Jul 20 '05 #3

And:
[dongfang@granad a xslt-examples]$ xsltproc --version
Using libxml 20606, libxslt 10033 and libexslt 722
xsltproc was compiled against libxml 20511, libxslt 10033 and libexslt 722
libxslt 10033 was compiled against libxml 20511
libexslt 722 was compiled against libxml 20511

Jul 20 '05 #4
As I get it, they should have been identical??


yes, they should.

David
Jul 20 '05 #5
David Carlisle wrote:
As I get it, they should have been identical??


yes, they should.

David


Thanks David,

Getting confused is not that bad after all then, when what you are
trying to convince yourself about is wrong....

Soren

Jul 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2567
by: Design Pattern Catalog | last post by:
Thank you for your interest in "Design Patterns: Elements of Reusable Object-Oriented Design", by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides. This message answers several frequently asked questions. If you thought you were asking for the source code, you must have made a mistake. Please try again! The "pattern home page", with all this information and more, is at...
0
1171
by: Steve Jorgensen | last post by:
In a schema I've been working on recently, a convention I evolved was to use a consistent naming pattern such that, for instance, a Resident could appear in a ResidentSet, and could be referred to by a ResidentRef, and the same pattern would apply to other types of entities. That amounts to a lot of duplication in the schema, though, and results in a need to enforce consistency in how the naming convention is applied. A solution I've...
13
6562
by: John Salerno | last post by:
Here are a few I'm considering: Design Patterns Explained : A New Perspective on Object-Oriented Design (2nd Edition) (Software Patterns Series) by Alan Shalloway Design Patterns C# by Steven John Metsker Design Patterns by Erich Gamma Head First Design Patterns by Elisabeth Freeman
12
1913
by: Jeff | last post by:
I'm just getting up to speed on OOP patterns (e.g, MVC) and I'm wondering how closely they are followed out in the real world. Do those of you who use them try to follow them as closely as possible and deviate only as necessary? Or do you only generally follow them; mix-n-match as necessary? Just wondering what I should be looking to accomplish with OOP patterns in general. Thanks!
1
6530
by: JosAH | last post by:
Greetings, this week we let go of all that algebraic stuff and concentrate a bit more on what object oriented programming is all about. Java claims to support OO, so why not use it? In this week's article we're going to talk a bit about when and why to apply certain patterns. We'll start with the Visitor pattern. The pattern is also named 'double dispatch' which will become clear near the end of this little article. Here's the...
7
3106
by: =?Utf-8?B?bWF2cmlja18xMDE=?= | last post by:
Hi, I would like to know more about design patterns and specifically using C#. Can any one recommend a good book? Thanks
4
14731
weaknessforcats
by: weaknessforcats | last post by:
Design Patterns – State Often computer software operates based on a condition called a state. These states traditionally have been implemented using a switch statement. The cases of the switch represent the various states. The example below might be used to read a disc file int state = 1; switch (state) { case 1: //open the file
9
3460
by: Christian Hackl | last post by:
Hi! I've got a design question related to the combination of the NVI idiom (non-virtual interfaces, ) and popular object-oriented patterns such as Proxy or Decorator, i.e. those which have the basic idea of deriving from a base class and delegating to an object of it at the same time. My problem is that I cannot seem to combine those two techniques in a flawless way. For a very simple, non real life example (for which I shall omit...
4
1352
by: John Sheppard | last post by:
Hello, I am working on a 3teired project, data,bizlogic, userinterface...I have a global class that at current is being passed around as parameters, this is, to say the least messy... I am reading up about singletons, but I wonder where to place it? Should I stick it in with the userinterface....how do I make it globally accessable if its in a different layer/project...
0
9538
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
10470
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
10247
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...
1
10214
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7561
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5459
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5583
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4135
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
3
2935
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.