Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] targeting the last element in a node or consecutive elements

From: egarrett@------------
To:
Date: 1/4/2007 8:43:00 PM
This appears to be working:

               <xsl:apply-templates select="node()[not(self::processing-
instruction()[not(following-sibling::*)])]"/>

Then I insert the extra element.  Then grab the PIs I suppressed above:
               <xsl:apply-templates select="node()[self::processing-
instruction()[not(following-sibling::*)]]"/>

Does it look right?

Thanks.
--emily

----- Original Message -----
From: <egarrett@xxxxxxxxxxxx>
Date: Thursday, January 4, 2007 2:21 pm
Subject: Re: [xsl] targeting the last element in a node or consecutive 
elements
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx

> Here is my logic so far to target everything in the node, and if 
> it is 
> a processing-instruction it should be processed only if something 
> exists after it other than another processing-instruction.  What I 
> have 
> below does not work because I think it is looking for the second 
> processing-instruction inside the first one rather than following 
> it, 
> but it is starting to feel like it is possible to put what I need 
> in 
> one instruction.
> 
> <xsl:apply-templates select="node()[not(self::processing-instruction()
> [not(following::*[not(self::processing-instruction())])])]"/>
> 
> Warning: on line 58 of file:/C:/Documents%20and%
> 20Settings/egarrett/Desktop/Transforms%20R%20Us/saxon/xsl/X3B.xsl:
>  The self axis will never select any element() nodes when 
> starting at 
> an
>  processing-instruction() node
> 
> Any ideas?
> ----- Original Message -----
> From: egarrett@xxxxxxxxxxxx
> Date: Thursday, January 4, 2007 9:59 am
> Subject: Re: [xsl] targeting the last element in a node or 
> consecutive 
> elements
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> 
> > Yes, your example is correct.  I don't know if or how many PIs 
> > will 
> > occur at the end of the node.
> > 
> > P.S. I started a new post because they changed the 
> > requirements....   
> > 
> > ----- Original Message -----
> > From: Abel Braaksma <abel.online@xxxxxxxxx>
> > Date: Thursday, January 4, 2007 9:53 am
> > Subject: Re: [xsl] targeting the last element in a node or 
> > consecutive 
> > elements
> > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > 
> > > Hi Emily,
> > > 
> > > This is a double post, you already opened this discussion 
> under 
> > > "suppressing only the last PI" (which differed in details, 
> however).> > 
> > > If I may, it appears that you want to do this:
> > > 
> > > <somenode>
> > >    <node1 />
> > >    <?instr1?>
> > >    <node2 />
> > >    <?instr2?>
> > >    <?instr3?>
> > > </somenode>
> > > 
> > > 1. Process node1, instr1, node2 etc
> > > 2. Do something before instr2 and instr3 (being consecutively 
> > and 
> > > together at the end of a node)
> > > 3. Process instr2 and instr3
> > > (if instr2 and instr3 were not there, you want to skip 
> > processing 
> > > step 2 
> > > and 3?)
> > > 
> > > Am i right? Please confirm (and/or give your sample input, to 
> > make 
> > > the 
> > > subject easier)
> > > 
> > > Cheers,
> > > -- Abel
> > > 
> > > Emily.Garrett@xxxxxxxxxxx wrote:
> > > > I'm trying to use xsl:apply templates to grab the entire 
> > content 
> > > of a
> > > > node, except for any PIs that may be at the very end of the 
> > > node.  I can
> > > > see how position()=last() can be used to refer to the very 
> > last 
> > > PI, but
> > > > how would I refer to possibly 2 or 3 PIs that are at the end 
> > of 
> > > the node
> > > > (not knowing what they are or how many), but still process 
> PIs 
> > > that are
> > > > contained elsewhere in this content?   Is there some syntax 
> > that 
> > > refers> to consecutive elements or refers to an element that 
> is 
> > > the last one in
> > > > a node, not knowing what element it is?
> > > >
> > > > Here is explanation for what I'm trying to do:   
> > > >
> > > > Process all content, unless they are PIs that occur 
> > > consecutively at the
> > > > very end of the node.
> > > >
> > > > Then I have to insert an element, then process these PIs 
> that 
> > occur> > consecutively at the very end of the node.
> > > >
> > > > I'm having trouble narrowing down my research on this one.  
> > Does 
> > > anyone> have any ideas?
> > > >
> > > > Thanks,
> > > > Emily


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent