Subject: Re: [xsl] Re parsing element data generated by XSLT within the same stylesheet From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Tue, 29 Dec 2009 13:50:15 -0500 |
I'm trying to learn XSLT (better).
I'm working with an existing complicated stylesheet that I need to make changes to.
I have a working solution where I output the XSLT piped to XQuery (which I know better) but I'd like to do the whole thing in XSLT.
The basic concept/solution I'm looking for is: is it possible, and how, to re-process generated elements that are not in the source document.
Simplified example: suppose I have a template like this. Suppose I have LOTS of templates like these.
<xsl:template match="v3:renderMultiMedia/v3:caption"> <p> <xsl:call-template name="styleCodeAttr"> <xsl:with-param name="styleCode" select="@styleCode"/> <xsl:with-param name="additionalStyleCode" select="'MultiMediaCaption'"/> </xsl:call-template> <xsl:apply-templates select="@*[not(local-name(.)='styleCode')]"/> <xsl:apply-templates mode="mixed" select="node()"/> </p> </xsl:template>
What I'd like to do is change every <p>XXX</p> into XXX
<xsl:variable name="intermediate" as="element(p)*"> <xsl:apply-templates/><!--this is what you are doing now--> </xsl:variable> <xsl:for-each select="$intermediate"> <xsl:copy-of select="node()"/> <xsl:text> </xsl:text> </xsl:for-each>
<xsl:variable name="intermediate" as="element(p)*"> <xsl:apply-templates/><!--this is what you are doing now--> </xsl:variable> <xsl:apply-templates select="$intermediate" mode="change-p-to-nl"/> ... <xsl:template mode="change-p-to-nl" match="p"> <xsl:copy-of select="node()"/> <xsl:text> </xsl:text> </xsl:template>
Obviously I can edit every template to change how it generates the output XML, but I'm wondering is there a way to do this in XSLT by saying "Re-parse the generated XML by this template".
-- UBL and Code List training: Copenhagen, Denmark 2010-02-08/10 XSLT/XQuery/XPath training after http://XMLPrague.cz 2010-03-15/19 XSLT/XQuery/XPath training: San Carlos, California 2010-04-26/30 Vote for your XML training: http://www.CraneSoftwrights.com/s/i/ Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18 Video overview: http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18 G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Re parsing element data gener, David A. Lee | Thread | Re: [xsl] Re parsing element data g, David Carlisle |
[xsl] Re parsing element data gener, David A. Lee | Date | Re: [xsl] Re parsing element data g, David Carlisle |
Month |