xsl-list
[Top] [All Lists]

Re: [xsl] Transforming a Loose Structure

2007-03-21 19:31:37
Thanks,

I think i get the picture clearer now, I'll just create a template that will match for the patterns of the things that are not allowed and a different template that will match the things that are allowed.

I'll try this and report any progress and if i need further help on this.

Again, thanks!
--
*Jeff Sese*

David Carlisle wrote:
How can i achieve my desired results?

it seems from your example that your transformation of sub is to defer
generating the subscript element until you reach text node descendents
of the original element, so that's:


<?xml version="1.0" encoding="UTF-8"?>
<section>
<par>Test para <inline vertical-align="sub">test <inline font-style="italic">para1</inline> and more</inline> Test para</par>
</section>



<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <xsl:template match="*">
    <xsl:copy>
      <xsl:copy-of select="@*"/>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>


  <xsl:template match="inline[(_at_)role='italic']">
    <emphasis role="italic"><xsl:apply-templates/></emphasis>
  </xsl:template>

  <xsl:template match="inline[(_at_)vertical-align]">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="inline[(_at_)vertical-align='sub']//text()">
    <subscript><xsl:value-of select="."/></subscript>
  </xsl:template>


</xsl:stylesheet>




$ saxon8 inline2.xml inline2.xsl
<?xml version="1.0" encoding="UTF-8"?><section>
    <par>Test para <subscript>test </subscript><inline 
font-style="italic"><subscript>para1</subscript></inline><subscript> and more</subscript> Test 
para</par>
</section>

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>