Subject: RE: [xsl] How can I test the last preceding text character? From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Mon, 29 Oct 2007 21:37:27 -0000 |
Replace preceding-sibling::*[1]/text()[last()] with preceding-sibling::node()[1] If the preceding sibling is an element node, you'll get its string value automatically, you don't need to get it's text node children explicitly. There's also an ends-with() function in 2.0 which might be clearer than regular expressions for such a simple job. Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: Sascha Mantscheff [mailto:922492@xxxxxx] > Sent: 29 October 2007 21:28 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] How can I test the last preceding text character? > > How do I test if the very last character of any preceding > text - be it in a parent or a sibling - has a certain value? > Example: > > <a> > This is parent text a not ending with an x. > <d>This ends with an x</d> > <e>This should issue a message.</e> > This is parent text ending with an x </a> > > Now I want to know for each child element is if it is > preceded by an "x". > I can check the sibling with > > <xsl:if test="matches(preceding-sibling::*[1]/text()[last()],'x\$') "> > <xsl:message> > Element <xsl:value-of select="name()"/> is preceded by an x. > </xsl:message> > </xsl:if> > > But I cannot test the surrounding parent content with the > same model because the parent text may surround the child text. > > What's the way to do it?
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] How can I test the last p, Scott Trenda | Thread | RE: [xsl] How can I test the last p, Sascha Mantscheff |
RE: [xsl] How can I test the last p, Scott Trenda | Date | RE: [xsl] How can I test the last p, Sascha Mantscheff |
Month |