[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Extract attribute and make processing instructions

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
Re:  Extract attribute and make processing instructions
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).

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.