Subject: Re: [xsl] Template matching preceding-sibling. From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Mon, 19 Nov 2007 14:50:23 -0500 |
Right. One way of addressing this is to show us exact code with input and results (pasted please) in minimal form and also tell us what processor you're running. There are list readers who run several different processors in order to check exactly this kind of thing, and can confirm what you're seeing or help to analyze relevant factors if they can't. Also, we can collectively establish quite quickly what a processor should be doing in a given specific case -- that is, the relevant expertise is available to expose mistaken assumptions and even reasonable but incorrect interpretations.
The funniest thing is, that in my very first post I did include all inputs and outputs, copy-pasted. But all XSLT-related responses I got so far were about this "...[... != ...]" expression - I guess that's because members immediately spot this commonly misunderstood expression and suppose it is the problem I'm addressing, without reading attentively my whole message (and Michael Key's response is an obvious cue of this).
match="Rec[activity != preceding-sibling::Rec/activity or not(preceding-sibling::Rec)]"
<Rec> <activity>swimming</activity> </Rec> <Rec> <activity>biking</activity> </Rec> <Rec> <activity>boating</activity> </Rec> <Rec> <activity>swimming</activity> </Rec>
Cheers, Wendell
Just in case if somebody is still interested in this issue I'll quote here this
message, but personally, now I almost 100% sure that it's ok and the input
is transformed correctly with this template.
Date: Wed, 14 Nov 2007 10:00:53 +0600 To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> From: "Ilya Konanykhin" <ilya.konanykhin.ml@xxxxxxxxx> Subject: Re: [xsl] Template matching preceding-sibling. Message-ID: <00a701c82672$f52f63b0$0200a8c0@KRYGER>
Hi, list!
I'm asking for clarification of the topic being on the list several days ago (Nov 8). Steve <subsume@xxxxxxxxx> wrote:
I'm missing something fundamental, what is it?
<xsl:template match="Rec[activity != preceding-sibling::Rec/activity or not(preceding-sibling::Rec)]"> Ello xslers. </xsl:template>
<xml> <Rec> <activity>hi</activity> </Rec> <Rec> <activity>hi</activity> </Rec> </xml>
----
Above should only print anything once, but I'm getting it each time. What am I not getting?
Charles Knell and Scott Trenda gave advices/made notices, thus confirming, that the problem exists. But copying the input data and the template given by Steve and running it I obtained exactly the result required by him in the first topic-forming message, if I understood his request correctly. I used MSXML (not sure about version, but don't think it's important in this simple case) and Saxon 9, for the latter I also tried changing template version to 2.0 - the result stood the same. Data follows:
----------- input.xml: <?xml version="1.0"?>
<xml> <Rec> <activity>hi</activity> </Rec> <Rec> <activity>hi</activity> </Rec> </xml>
----------- input.xsl: <?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="Rec[activity != preceding-sibling::Rec/activity or not(preceding-sibling::Rec)]"> Ello xslers. </xsl:template>
</xsl:stylesheet>
----------- output.xml: <?xml version="1.0" encoding="UTF-8"?>
Ello xslers.
hi
-----------
As it is clearly seen the string "Ello xslers" appears only once and not twice as Steve wrote ("hi" comes from the defaul copy rules, as I understand it).
Did I missed or misunderstood something very basic? Can someone please reveal the trick to me (especially interested in Charles' oppinion as he was involved most intensively in the discussion).
Many thanks in advance, Ilya
Cheers, Ilya
====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Template matching precedi, Ilya Konanykhin | Thread | Re: [xsl] Template matching precedi, Ilya Konanykhin |
Re: [xsl] xml to xml issue in XSLT2, chun ji | Date | Re: [xsl] Table of contents for all, G. Ken Holman |
Month |