Subject: RE: [xsl] hard xsl problem From: "Sal Mangano" <smangano@xxxxxxxxxx> Date: Mon, 26 Jul 2004 12:14:23 -0400 |
Michael, It is cool to see we came upon the same basic solution. As I hinted in my response it is a lot easier in XSLT 2.0. I love 2.0! It really raises the bar on what you can do (easily) with XSLT. -Sal > -----Original Message----- > From: Michael Kay [mailto:mhk@xxxxxxxxx] > Sent: Monday, July 26, 2004 6:10 AM > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: RE: [xsl] hard xsl problem > > > Handling implicit structure is always easier in XSLT 2.0, > though this one is still a little tricky. > > I would do a first pass in which all the "(" characters (and preceding > whitespace) are replaced by <lpar/> and all the ")" (and following > whitespace) are replaced by <rpar/>. This is easily done in > 2.0 using xsl:analyze-string. > > <xsl:template match="text()"> > <xsl:analyze-string select="." regex="(\s*\()|(\)\s*)"> > <xsl:matching-substring> > <xsl:choose> > <xsl:when test="contains(.,'(')><lpar/></xsl:when> > <xsl:otherwise><rpar/></xsl:otherwise> > </ > </ > </ > </ > > > Then in a second pass, use: > > <xsl:for-each-group group-starting-with="lpar|rpar"> > <xsl:if test="self::rpar"> > <xsl:copy-of select="current-group() except ."/> > </ > </ > > Not tested. > > Michael Kay > > > -----Original Message----- > > From: Richard Bondi [mailto:rbondi@xxxxxxxxx] > > Sent: 26 July 2004 00:10 > > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > > Subject: [xsl] hard xsl problem > > > > I would be grateful for a solution to the following xsl problem. > > > > Example input: > > ============== > > <Paragraph> On October 30, clad in scarlet and ermine, Charles made > > his entry into the papal palace (see <i>especially<i> > <cite>30</cite>, > > as well as <cite>20</cite>). He presented the Pope with a > blue velvet > > cape embroidered in pearls (<cite>234</cite>; > <cite>12345</cite>) in a > > design of angels (as well as a fleur-de-lys and stars). With no > > footing except in French support, Clement's papacy would > have vanished > > in smoke.</Paragraph> > > > > Example output: > > ============== > > <Paragraph> On October 30, clad in scarlet and ermine, Charles made > > his entry into the papal palace. He presented the Pope with a blue > > velvet cope embroidered in pearls in a design of angels (as > well as a > > fleur-de-lys and stars). With no footing except in French support, > > Clement's papacy would have vanished in smoke.</Paragraph> > > > > Problem in words: > > ============== > > The <cite> tags are always enclosed in parenthesis. As the > result of a > > transform (when a parameter passed into the xsl sheet is > 'true') (a) > > these parens, (b) their xml content, and (c) the space > preceding the > > open paren must be suppressed. Alternatively, (a)-(c) can > be enclosed > > in a tag. Parens that do not contain <cite> tags are to be > left as is. > > All of this is always inside a <Paragraph> tag. > > > > How to do this is the problem. > > > > I don't see how to do this even with a plugin, because it > is unclear > > to me how a plugin can be used to generate tags. It would > of course be > > more elegant to do this without a plugin. > > > > MTIA, > > /r:b:
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] hard xsl problem, Michael Kay | Thread | RE: [xsl] hard xsl problem, Michael Kay |
Re: [xsl] XSL resources - Flat to h, M. David Peterson | Date | RE: [xsl] hard xsl problem, Michael Kay |
Month |