Hi,
this is my xml document :
<?xml version="1.0" ?>
<ROOT>
<Group>Group</Group>
<Name>Name</Name>
<TitleName>TitleName</TitleName>
<SubTitleName>Sub</SubTitleName>
<Chapter>
<ChapterHead>
<ChapterName>ChapterName</ChapterName>
<ChapterNameText>ChapterNameTest
</ChapterNameText>
</ChapterHead>
<ChapterLine>
<Paragraph>Paragraph</Paragraph>
<TextLine>TextLine</TextLine>
</ChapterLine>
</Chapter>
</ROOT>
#------------------
and this is the xsl :
<?xml version="1.0" encoding="iso-8859-1" ?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text" encoding="ISO-8859-1"/>
<xsl:output media-type="text/plain"/>
<xsl:template match="ROOT">
<xsl:apply-templates select="Group | Name |
TitleName | SubTitleName | Chapter"/>
</xsl:template>
<xsl:template match="Group">
<xsl:value-of select="."/>
<xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="Name">
<xsl:value-of select="."/>
<xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="TitleName">
<xsl:value-of select="."/>
<xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="SubTitleName">
<xsl:value-of select="."/>
<xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="Chapter">
<xsl:apply-templates select="ChapterHead"/>
<xsl:apply-templates select="ChapterLine"/>
<xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="ChapterHead">
<xsl:apply-templates select="ChapterName"/>
<xsl:apply-templates select="ChapterNameText"/>
<xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="ChapterLine">
<i><xsl:apply-templates select="Paragraph"/></i>
<xsl:text> </xsl:text>
<xsl:apply-templates select="TextLine"/>
<xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="ChapterName">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="ChapterNameText">
<xsl:value-of select="."/>
<xsl:text> </xsl:text>
</xsl:template>
<xsl:template match="Paragraph">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="TextLine">
<xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet>
#-------------------------------------------------
And i use the java code found in the xalan examples to
do the transformation :
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.xml.transform.Transformer;
import
javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
/**
* Use the TraX interface to perform a transformation
in the simplest manner possible
* (3 statements).
*/
public class TransformXml2Html
{
public static void main(String[] args)
throws TransformerException,
TransformerConfigurationException,
FileNotFoundException, IOException
{
TransformerFactory tFactory =
TransformerFactory.newInstance();
Transformer transformer2 =
tFactory.newTransformer(new
StreamSource("GeneralTxt.xsl"));
transformer2.transform(new StreamSource("xxx.xml"),
new StreamResult(new FileOutputStream("xxx.txt")));
transformer2.transform(new StreamSource("xxx.xml"),
new StreamResult(new FileOutputStream("xxx.txt")));
System.out.println("************* The result is in
xxx.txt *************");
}
}
#------------------------------------------------
I tried to insert external parameters in the xsl code
without success. How i can do that?
Thanks in advance
ro
--- cknell(_at_)onebox(_dot_)com wrote: > > It's possible to do
that ?
Yes.
and how?
It depends on how you are doing the
transformation (what XSLT processor are you using?).
--
Charles Knell
cknell(_at_)onebox(_dot_)com - email
-----Original Message-----
From: Roberta Granata <robgranata(_at_)yahoo(_dot_)co(_dot_)uk>
Sent: Mon, 29 Mar 2004 14:53:11 +0100 (BST)
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] It's possible to give external
parameters in xslt?
Hello all,
I' m new in xslt , and i have a problem when i
convert
an xml document in a txt document by xslt to give
external parameters.It's possible to do that ? and
how?
Thanks in advance
ro
___________________________________________________________
WIN FREE WORLDWIDE FLIGHTS - nominate a cafe in the
Yahoo! Mail Internet Cafe Awards
www.yahoo.co.uk/internetcafes
--+------------------------------------------------------------------
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>
--+--
___________________________________________________________
WIN FREE WORLDWIDE FLIGHTS - nominate a cafe in the Yahoo! Mail Internet Cafe
Awards www.yahoo.co.uk/internetcafes