Hi,
bei folgendem Script bekomme ich in keinster Weise eine Textausgabe (xsl:text) hin:
XSLT
<pre>
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="text" />
<xsl:template match="/books">
<xsl:value-of select="' '"/>
<xsl:text>asodiöaisödkasödkalöksödkaöskdökaösdöakl ösd</xsl:text>
<xsl:for-each select="$items">
<xsl:text>"</xsl:text>
<xsl:value-of select="."/>
<xsl:text>",</xsl:text>
</xsl:for-each>
<xsl:value-of select="' '"/>
</xsl:template>
</xsl:stylesheet>
</pre>
XML:
<pre>
<?xml version='1.0'?>
<!-- This file represents a fragment of a book store inventory database -->
<bookstore>
<book genre="autobiography" publicationdate="1981" ISBN="1-861003-11-0">
<title>ZZZZThe Autobiography of Benjamin Franklin</title>
<author>
<first-name>Benjamin</first-name>
<last-name>Franklin</last-name>
</author>
<price>8.99</price>
</book>
<book genre="novel" publicationdate="1967" ISBN="0-201-63361-2">
<title>The Confidence Man</title>
<author>
<first-name>Herman</first-name>
<last-name>Melville</last-name>
</author>
<price>11.99</price>
</book>
<book genre="philosophy" publicationdate="1991" ISBN="1-861001-57-6">
<title>The Gorgias</title>
<author>
<name>Plato</name>
</author>
<price>9.99</price>
</book>
</bookstore>
</pre>
Code:
<pre>
String filename = "books.xml";
String stylesheet = "output.xsl";
//Load the stylesheet.
XslTransform xslt = new XslTransform();
xslt.Load(stylesheet);
//Load the file to transform.
XPathDocument doc = new XPathDocument(filename);
FileStream f = new FileStream("C:\\temp\\output.txt",FileMode.Create) ;
StreamWriter s = new StreamWriter(f);
XmlTextWriter writer = new XmlTextWriter(s);
//Transform the file and send the output to the console.
xslt.Transform(doc, null, writer);
s.Close();
f.Close();
</pre>
<br>Danke schon mal für die Hilfe.
<br>
<br>mfg
<br>PS
bei folgendem Script bekomme ich in keinster Weise eine Textausgabe (xsl:text) hin:
XSLT
<pre>
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="text" />
<xsl:template match="/books">
<xsl:value-of select="' '"/>
<xsl:text>asodiöaisödkasödkalöksödkaöskdökaösdöakl ösd</xsl:text>
<xsl:for-each select="$items">
<xsl:text>"</xsl:text>
<xsl:value-of select="."/>
<xsl:text>",</xsl:text>
</xsl:for-each>
<xsl:value-of select="' '"/>
</xsl:template>
</xsl:stylesheet>
</pre>
XML:
<pre>
<?xml version='1.0'?>
<!-- This file represents a fragment of a book store inventory database -->
<bookstore>
<book genre="autobiography" publicationdate="1981" ISBN="1-861003-11-0">
<title>ZZZZThe Autobiography of Benjamin Franklin</title>
<author>
<first-name>Benjamin</first-name>
<last-name>Franklin</last-name>
</author>
<price>8.99</price>
</book>
<book genre="novel" publicationdate="1967" ISBN="0-201-63361-2">
<title>The Confidence Man</title>
<author>
<first-name>Herman</first-name>
<last-name>Melville</last-name>
</author>
<price>11.99</price>
</book>
<book genre="philosophy" publicationdate="1991" ISBN="1-861001-57-6">
<title>The Gorgias</title>
<author>
<name>Plato</name>
</author>
<price>9.99</price>
</book>
</bookstore>
</pre>
Code:
<pre>
String filename = "books.xml";
String stylesheet = "output.xsl";
//Load the stylesheet.
XslTransform xslt = new XslTransform();
xslt.Load(stylesheet);
//Load the file to transform.
XPathDocument doc = new XPathDocument(filename);
FileStream f = new FileStream("C:\\temp\\output.txt",FileMode.Create) ;
StreamWriter s = new StreamWriter(f);
XmlTextWriter writer = new XmlTextWriter(s);
//Transform the file and send the output to the console.
xslt.Transform(doc, null, writer);
s.Close();
f.Close();
</pre>
<br>Danke schon mal für die Hilfe.
<br>
<br>mfg
<br>PS