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

Re: From WordprocessingML inline styles to nested inli

Subject: Re: From WordprocessingML inline styles to nested inline elements
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 21 Mar 2007 15:22:33 GMT
Re:  From WordprocessingML inline styles to nested inli
> In my output, however, the inline styles should nest, and moreover, nest 
> in a particular order:

something like

$ saxon wp1.xml wp1.xsl
<?xml version="1.0" encoding="utf-8"?><run><b><i>This is text in bold and italic.</i></b></run>
davidc@souldern /c/tmp
$ cat wp1.xml
<w:r xmlns:w="data:,w">
   <w:rPr>
     <w:i/>
     <w:b/>
   </w:rPr>
   <w:t>This is text in bold and italic.</w:t>
</w:r>

$ cat wp1style.xml 

<style_nesting>
   <b><i><u/></i></b>
</style_nesting>


$ cat wp1.xsl
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:w="data:,w"
 exclude-result-prefixes="w">

<xsl:variable name="s" select="document('wp1style.xml')/style_nesting"/>

<xsl:template match="w:r">
  <run>
    <xsl:apply-templates mode="s" select="$s">
      <xsl:with-param name="t" select="w:t"/>
      <xsl:with-param name="p" select="w:rPr"/>
    </xsl:apply-templates>
  </run>
</xsl:template>


<xsl:template match="*" mode="s">
  <xsl:param name="t"/>
  <xsl:param name="p"/>
  <xsl:choose>
    <xsl:when test="$p/*[local-name()=local-name(current())]">
      <xsl:copy>
        <xsl:apply-templates mode="s" select="*">
          <xsl:with-param name="p" select="$p"/>
          <xsl:with-param name="t" select="$t"/>
        </xsl:apply-templates>
      </xsl:copy>
    </xsl:when>
    <xsl:otherwise>
      <xsl:apply-templates mode="s" select="*">
        <xsl:with-param name="p" select="$p"/>
        <xsl:with-param name="t" select="$t"/>
      </xsl:apply-templates>
    </xsl:otherwise>
  </xsl:choose>
  <xsl:if test="not(*)">
    <xsl:value-of select="$t"/>
  </xsl:if>
</xsl:template>
  



</xsl:stylesheet>

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.