Subject: [xsl] Basic again: if condition and processing From: "Hubert Holtz" <Turnhose_alt@xxxxxxx> Date: Mon, 30 Dec 2002 13:42:17 +0100 |
Thank you for your help Joerg or just: Dank'schön But I have another question about XSL processing. I have two sect1 elements in my article with different language attributes, depending on an url parameter I want to process the english or german section. I thought of something like that: <xsl:template match="sect1"> <xsl:if sect1="@lang='eng'"> <xsl:apply-templates select="sect1[@lang='eng']"/> </xsl:if> <xsl:if sect1="@lang='ger'"> <xsl:apply-templates select="sect1[@lang='ger']"/> </xsl:if> but then I have to copy nearly the whole xsl content into the second template too, and I know that's not the way to do it, because both sect1 elements(eng,ger) are structured in the same way, only different content, of course. So my XML looks like thtat: <sect1 lang="eng"> <title></title> <para> english bla ... <sect1 lang="ger"> <title></title> <para> deutsch bla ... So depending on my url parameter (e.g. ?lang=ger) I want to process all with lang="ger" attribute in my XML file and the same way with lang="eng". Thanks in advance. Homer30 *********** REPLY SEPARATOR *********** On 30.12.2002 at 12:29 Joerg Pietschmann wrote: >On Monday 30 December 2002 11:42, "Hubert Holtz" wrote: >> I have a simple article with some parameters, and in this paramter I want >You probably mean "paragraphs" instead of "parameter". > >> to put some links, but the final html file puts the link under the text >and >> not at the position in the text. >The paragraph is text mixed with elements. You use pull style >processing (xsl:for-each). Push style processing is much better >suited for processing mixed content. >Declare templates for processing <para> and <ulink> >elements and use xsl:apply-templates to apply them: ><xsl:template match="sect1[@lang='ger']"> > <table ... > <tr> > <td> > <xsl:apply-templates select="para"/> > </td> > ... ></xsl:template> ><xsl:template match="para"> > <xsl:apply-templates/> > <br/><br/> ></xsl:template> ><xsl:template match="ulink"> > <a href="{@url}"> > <xsl:choose> > <xsl:when test="count(child::node())=0"> > <xsl:value-of select="@url"/> > </xsl:when> > <xsl:otherwise> > <xsl:apply-templates/> > </xsl:otherwise> > </xsl:choose> > </a> ></xsl:template> > >The default templates will take care of copying text through. > >J.Pietschmann > > 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] Basic question: placing a, Joerg Pietschmann | Thread | Re: [xsl] Basic again: if condition, Joerg Heinicke |
Re: [xsl] RTF Output, Joerg Pietschmann | Date | [xsl] Partial Matching For, Divakar Satyanarayan |
Month |