Subject: RE: [xsl] Putting characters in an element From: "Sergiu Ignat" <sergiu@xxxxxxxxxx> Date: Thu, 2 Oct 2003 16:03:06 +0300 |
Harm, are you sure that the dot "." is an acceptable character for an element name in XML? I don't think so. Maybe you should try to add attributes like <li nr="1">1.</li>. Sergiu > Hi, > > I am having the following problem. I would like to put a list > number in > a seperate element and preserve the other in-line elements. > > input: > <?xml version="1.0"?> > <root> > <al>1. This is some very <emphasis>important</emphasis> tekst.</al> > <al>2. And a second line</al> > <al>And a last line</al> > </root> > > desired output: > <li><li.nr>1.</li.nr><al>This is some very > <emphasis>important</emphasis> tekst.</al></li> > <li><li.nr>2.</li.nr><al>And a second line</al></li> > <al>And a last line</al> > > I can use XSLT 2 for the solution, but even with this I have not been > able to solve the problem. > I have tried the following solution. It works perfectly with strings, > but the inline element <emphasis> is not copied to the output. > > Stylesheet: > <xsl:template match="al"> > <xsl:param name="first-string"> > <xsl:value-of select="substring-before(., ' ')"/> > </xsl:param> > > <xsl:choose> > <xsl:when test="matches($first-string,'\d')"> > <li> > <xsl:analyze-string select="." regex="^\d\. "> > <xsl:matching-substring> > <nr><xsl:value-of select="."/></nr> > </xsl:matching-substring> > <xsl:non-matching-substring> > <al><xsl:copy-of select="."/> > </al> > </xsl:non-matching-substring> > </xsl:analyze-string> > </li> > </xsl:when> > <xsl:otherwise> > <al><xsl:copy-of select="descendant::node()"/></al> > </xsl:otherwise> > </xsl:choose> > </xsl:template> > > How can I achieve this without nodes in stead of strings (in > XSLT1.0 or > XSLT2.0)? > > Regards, > > Harm > > > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Putting characters in an , Harm Kok | Thread | Re: [xsl] Putting characters in an , Jeni Tennison |
RE: [xsl] Parameter problem, Americo Albuquerque | Date | Re: [xsl] Putting characters in an , David Carlisle |
Month |