Subject: RE: [xsl] How to perse the whole source document From: "Mohammed Rahman" <mrahman@xxxxxxxxxxxx> Date: Tue, 29 May 2001 15:53:35 -0700 |
Hi jeni, I've tried the templates but it did not quite work properly. For each <sid> in the resulting xml, the xsl produces the result only for the first <para> group for the source xml. i.e the source xml ... <article> <section name="S01"> <para seq="P01.01"> aaa </para> <para seq="P01.01"> bbb </para> <para seq="P01.02"> xxx </para> <para seq="P01.02"> yyy </para> <section name="S01.01"> <para seq="P01.01.01"> mmm </para> <para seq="P01.01.01"> nnn </para> <para seq="P01.02.01"> ppp </para> <para seq="P01.02.01"> rrrr </para> </section> </section> </article> The out put produced only for : <para seq="P01.02"> xxx </para> <para seq="P01.02"> yyy </para> ----- and ------ <para seq="P01.02.01"> ppp </para> <para seq="P01.02.01"> rrrr </para> Is there any remedy? Regards, Mo -----Original Message----- From: Jeni Tennison [mailto:mail@xxxxxxxxxxxxxxxx] Sent: Saturday, May 26, 2001 1:13 AM To: Mohammed Rahman Cc: XSL-List@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] How to perse the whole source document Hi Mo, The XSLT is parsing the entire source document, it's just that you're only accessing part of it. You're stepping through the content of a section element one node at a time in order to group the para elements. However, when you find a para element, you're only moving on to the next para element with the same name - if there isn't one you stop, so the section elements afterwards are ignored. Perhaps it'd be better to try a different approach - apply templates to everything and test within a template what you need to do. So, when you find a section element, create a sid and apply templates to everything inside it: <xsl:template match="section"> <sid> <xsl:apply-templates /> </sid> </xsl:template> When you find a para element, test whether its preceding sibling is a para element with the same name as it has - if it is, do nothing, if it isn't, do all the funky stuff you want to do with the para element: <xsl:template match="para"> <xsl:variable name="as" select="@name" /> <xsl:if test="preceding-sibling::para[1]/@name != $as"> <text name="{$as}"> <xsl:apply-templates select="." mode="content" /> <xsl:copy-of select="document('doc2.xml') /TableName/RecordName[normalize-space(name) = $as] /*[not(self::name)]" /> </text> </xsl:if> </xsl:template> <xsl:template match="para" mode="content"> <xsl:copy-of select="node()" /> <xsl:text>
</xsl:text> <xsl:apply-templates mode="content" select="following-sibling::*[1][@name = current()/@name]" /> </xsl:template> I hope that helps, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] How to perse the whole so, Jeni Tennison | Thread | Re: [xsl] How to perse the whole so, Jeni Tennison |
RE: [xsl] XML serializer implemente, Evan Lenz | Date | [xsl] How to avoid duplicated items, Ramnivas Laddad |
Month |