RE: [xsl] testing for position of an element and displaying it accordingly

Subject: RE: [xsl] testing for position of an element and displaying it accordingly
From: ms <mina_hurray@xxxxxxxxx>
Date: Tue, 23 Jan 2007 14:59:14 -0800 (PST)
Hello Michael:

Please bear with me as I try to understand stuff here.
I do understand the tree structure in XML. My problem
is that I want to apply the numbering for the element
r1 itself and not to any of its children. Basically, I
want to make a list starting from r1-r10. Each element
(r1-r10) should be numbered. So since I apply the
numbering to r1 inside the r1 template, its children
come under the numbering which I do not want to
happen. I want the children to appear without the
numbering and 
so the issue I face is as soon as the processor hits
<r1>, it automatically puts number 1. and then
processes other elements. That is the reason to used
modes in my style sheet so that even though these
elements are children of <r1> they should not be
numbered. 

am I still misunderstanding this concept?  


 
--- Michael Kay <mike@xxxxxxxxxxxx> wrote:

> 
> I assume you're the same person as xslt.new who
> posted "axis specifiers"
> last week (if not, it's a remarkable that you have
> exactly the same problem
> and the same misunderstandings).
> 
> We need to go back a step. You haven't understood a
> word of the explanations
> we gave you last week. Giving you the same
> explanations again isn't going to
> do much good. I'm really trying hard to read your
> postings and work out
> which step in the learning process you've got stuck
> on, but I'm struggling. 
> 
> The normal way of processing an XML document is to
> work top-down. First, you
> have to think of the document as a tree, with the
> root at the top (strange
> in botany, but not in computing). The document node
> itself is at the top,
> then the r1 element, and (a,a,b,a) are below the r1
> element, at the next
> level down (I stress this because you talk of test3
> as being "below" b,
> which means you're not yet thinking in tree terms).
> So top down processing
> means you write a template rule for r1, which
> typically applies templates to
> each of its children. You then define template rules
> for each kind of child.
> 
> This works when the rules for an element are
> independent of where it appears
> relative to other elements at the same level. For
> example, if every a
> element is processed by converting the <a> tag to a
> <p>, then you can write
> a template rule
> 
> <xsl:template match="a">
>   <p><xsl:apply-templates/></p>
> </xsl:template>
> 
> Similarly, if every b is processed by outputting a
> <p> but with a sequence
> number attached, you can write
> 
> <xsl:template match="b">
>   <p><xsl:number/>: <xsl:apply-templates/></p>
> </xsl:template>
> 
> Now, your input and your processing seems to follow
> this conventional style.
> As far as we can see, you've got a perfectly
> straightforward easy
> transformation to do here that yields to the basic
> techniques in chapter 1
> of any textbook, and we can't see why you're making
> it so difficult.
> 
> Michael Kay
> http://www.saxonica.com/
> 
>  
> 
> > -----Original Message-----
> > From: ms [mailto:mina_hurray@xxxxxxxxx] 
> > Sent: 19 January 2007 14:58
> > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > Subject: [xsl] testing for position of an element
> and 
> > displaying it accordingly
> > 
> > Hi all:
> > 
> > My input XML looks like this;
> > 
> > <r1>
> > <a>test</a>
> > <a>test2</a>
> > <b>test test</b>
> > <a>test3</a>
> > </r1>
> > 
> > For this XML, I would like to write an XSLT which
> basically 
> > achieves the following:
> > 
> > 1) For the <a> elements which are above the <b>
> element, they 
> > should be displayed this way:
> > 
> > Test
> > Test2
> > 1)test test
> > 
> > 2) For the <a> element which appears after the <b>
> element, I 
> > want it displayed after the <b> element:
> > 
> > Test
> > Test2
> > 1)test test
> > test3
> > 
> > How can I achieve this in XSLT?  I tried testing
> the 
> > position, using position()=1. This works obviously
> for the 
> > first <a> element and fails for the second one. 
> > 
> > Please let me know if this is possible? 
> > 
> > 
> >  
> >
>
______________________________________________________________
> > ______________________
> > Do you Yahoo!?
> > Everyone is raving about the all-new Yahoo! Mail
> beta.
> > http://new.mail.yahoo.com
> 
> 



 
____________________________________________________________________________________
8:00? 8:25? 8:40? Find a flick in no time 
with the Yahoo! Search movie showtime shortcut.
http://tools.search.yahoo.com/shortcuts/#news

Current Thread