|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: xt pipeline
> i'm not clear exactly what you are doing in xslt, and what in java.
java, wassat? :-)
> maybe an example would help.
This is a simple case, but you can get finer control if you want it.
(But I can't be bothered to type anything in)
Starting from
====================================================================
<doc xmlns="one">
<head>test</head>
<section>
<head>one</head>
<p>this paragraph
this paragraph</p>
<p>another paragraph
another paragraph</p>
</section>
</doc>
====================================================================
You could use this stylesheet to get to html
====================================================================
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:one="one"
xmlns:two="two"
>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="one:doc">
<two:html>
<two:head>
<two:title><xsl:value-of select="one:head"/></two:title>
</two:head>
<two:body>
<two:h1><xsl:value-of select="one:head"/></two:h1>
<xsl:apply-templates select="one:section"/>
</two:body>
</two:html>
</xsl:template>
<xsl:template match="one:section">
<two:h2><xsl:value-of select="one:head"/></two:h2>
<xsl:apply-templates select="*[not(self::one:head)]"/>
</xsl:template>
<xsl:template match="one:p">
<two:p><xsl:apply-templates/></two:p>
</xsl:template>
</xsl:stylesheet>
====================================================================
which results in
====================================================================
<?xml version="1.0" encoding="utf-8"?>
<two:html xmlns:one="one" xmlns:two="two">
<two:head>
<two:title>test</two:title>
</two:head>
<two:body>
<two:h1>test</two:h1>
<two:h2>one</two:h2>
<two:p>this paragraph
this paragraph</two:p>
<two:p>another paragraph
another paragraph</two:p>
</two:body>
</two:html>
====================================================================
If you had an html to text stylesheet that looked like
====================================================================
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:t="two"
>
<xsl:output method="text"/>
<xsl:template match="t:head">
</xsl:template>
<xsl:template match="t:h1">
<xsl:value-of select="."/>
<xsl:text>
</xsl:text>
<xsl:value-of select="translate(.,'eston','=====')"/>
<xsl:text>

</xsl:text>
</xsl:template>
<xsl:template match="t:h2">
<xsl:value-of select="."/>
<xsl:text>
</xsl:text>
<xsl:value-of select="translate(.,'eston','-----')"/>
<xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="t:p">
<xsl:text>
 </xsl:text>
<xsl:apply-templates/>
<xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>
====================================================================
You could run that on the above output and get
====================================================================
test
====
one
---
this paragraph
this paragraph
another paragraph
another paragraph
====================================================================
Alternatively you could merge the two stylesheets and get one
stylesheet that does the work of two, like this
====================================================================
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:xt="http://www.jclark.com/xt"
extension-element-prefixes="xt"
>
<xsl:output method="text"/>
<xsl:import href="chain2.xsl"/>
<xsl:import href="chain1.xsl"/>
<xsl:template match="/">
<xsl:variable name="x">
<xsl:apply-templates/>
</xsl:variable>
<xsl:apply-templates select="xt:node-set($x)/*"/>
</xsl:template>
</xsl:stylesheet>
====================================================================
which produces the above text output if given the original document
modulo a spurious xml declaration that may or may not be a bug in xt
(I need to check what the spec says about xsl:import producing multiple
conflicting xsl:output )
David
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








