473,386 Members | 1,846 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,386 software developers and data experts.

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 1295
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@granada xslt-examples]$ cat position-fun.xml
<?xml version='1.0'?>
<warehouse>
<item name="foo">
<country>Argentina</country>
</item>
<item name="bar">
<country>Brazil</country>
</item>
<item name="baz">
<country>China</country>
</item>

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

<xsl:template match='warehouse'>
<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="position()"/>)
<xsl:copy-of select='.'/>
</first-country>
</xsl:template>

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

Output:
[dongfang@granada 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>Argentina</country></first-country>
<first-country>
(with "first", we mean: 4)
<country>Brazil</country></first-country>
<first-country>
(with "first", we mean: 6)
<country>China</country></first-country>
</first-try>
</position-experiment>
2nd stylesheet: Only difference is addition of child:: in match exp

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

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

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

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

Output:

[dongfang@granada xslt-examples]$ xsltproc position-fun22.xsl
position-fun.xml
<?xml version="1.0"?>
<position-experiment>
<first-try>
<country>Argentina</country>
<country>Brazil</country>
<country>China</country>
</first-try>
</position-experiment>
[dongfang@granada xslt-examples]$

Some difference there.

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

Soren

Jul 20 '05 #3

And:
[dongfang@granada 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
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...
0
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...
13
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...
12
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...
1
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...
7
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
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...
9
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...
4
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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...

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.