Subject: Re: Extract attribute and make processing instructions (1st instance)
From: Deborah Pickett <debbiep-list-xsl@xxxxxxxxxx>
Date: Mon, 26 Nov 2007 20:31:37 +1100
|
J. S. Rawat wrote:
> Is there any technique by which we can extract attribute (first
> instance) and make it processing instructions and process the tag as well.
I don't know how much more complex your real-world problem is than the
simplified one that you posted, but with your example I find it hard to
justify anything more complex than something like this.
<!-- not tested -->
<xsl:template match="*">
<xsl:if
test="@pg and (not(preceding::*[@pg])
or @pg != preceding::*[@pg][1])">
<xsl:processing-instruction name="p">
<xsl:value-of select="@pg"/>
</xsl:processing-instruction>
</xsl:if>
<xsl:element name="{local-name()}1">
<xsl:apply-templates select="@* | node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="@pg"/>
This may be insufficient if page numbers don't strictly increase, or if
you need to break a text node in the middle (because it straddles a page).
|