Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > <xsl:text> doesn't work with CR

Reply
Thread Tools

<xsl:text> doesn't work with CR

 
 
Paul Verbelen
Guest
Posts: n/a
 
      06-26-2006
I have a file with topics. I like to copy them in
another file but want to have some blank lines
between the different topics. I use <xsl:text>
element with as data some blank lines to perform
this. To clarify my question, I have add all the
files required to perform the test.

First question: Why doesn't this works anymore
if I remove the line with "&#x00A0;" in the
XSL-file ?

Second question: The [CDATA[ data in the XML-file
is converted in my output file (< becomes &lt;, etc.)
Is there a way to avoid this? I like to keep the
[CDATA[ syntax because it's more readable.


I have following script "test.js":

var myXml = "test.xml";
var myXsl = "test.xsl";
var myOut = "test.out";
var rSourceDoc,rStyleDoc;
var fso, f, ts, s;

rSourceDoc = new ActiveXObject("microsoft.xmldom");
rSourceDoc.async="false";
rSourceDoc.load(myXml);

rStyleDoc = new ActiveXObject("microsoft.xmldom");
rStyleDoc.async="false";
rStyleDoc.load(myXsl);

fso = new ActiveXObject("Scripting.FileSystemObject");
fso.CreateTextFile(myOut);
f = fso.GetFile(myOut);
ts = f.OpenAsTextStream(2);
ts.Write( rSourceDoc.transformNode(rStyleDoc) );
ts.Close( );

Which I run with batch "run.cmd":

cscript test.js

The data file "test.xml" is:

<?xml version="1.0"?>
<topicDb>
<topic>
This is a <b>test</b>
</topic>
<topic><![CDATA[
<H1>Titel</H1>
]]></topic>
</topicDb>

And the xsl file "test.xsl" is:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlnssl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="xml" version="1.0" indent="yes"/>
<xsl:template match="/">
<xsl:element name="topicDb">
<xsl:for-each select="*/topic">
<xsl:copy-of select="."/>
<xsl:text>
&#x00A0;


</xsl:text>
</xsl:for-each>
</xsl:element>
</xsl:template>
</xsl:stylesheet>

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      06-26-2006


Paul Verbelen wrote:


> Second question: The [CDATA[ data in the XML-file
> is converted in my output file (< becomes &lt;, etc.)
> Is there a way to avoid this? I like to keep the
> [CDATA[ syntax because it's more readable.


If you want to have the contents of certain elements as CDATA sections
in the output then you have to declare that e.g.
<xslutput cdata-section-elements="topic" />
This will however apply to all topic elements in the result tree, not
only to those in the input tree which have CDATA section content.





--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      06-26-2006


Paul Verbelen wrote:

Some suggestions not directly related to your questions:

> var myXml = "test.xml";
> var myXsl = "test.xsl";
> var myOut = "test.out";
> var rSourceDoc,rStyleDoc;
> var fso, f, ts, s;
>
> rSourceDoc = new ActiveXObject("microsoft.xmldom");
> rSourceDoc.async="false";
> rSourceDoc.load(myXml);
>
> rStyleDoc = new ActiveXObject("microsoft.xmldom");
> rStyleDoc.async="false";
> rStyleDoc.load(myXsl);


If you want to transform XML to XML then I would do e.g.
var resultDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
rSourceDoc.transformNodeToObject(rStyleDoc, resultDoc);
resultDoc.save(myOut);
instead of using the FileSystemObject.



--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE;Kontki if you delete kontiki any program you loaded with it in it 'will not work I have tried it with three programs and none work anymore (if you se it just stop download) 1-Twitch Computer Support 5 04-23-2009 02:45 PM
MS work around on text wrapping in a datagrid does not work TB ASP .Net 2 02-22-2006 10:34 PM
Hi I am new to asp i can not get it to work on xp pro sp2 even though the localhost work but asp pages dont so can some one help craig dicker ASP .Net 9 07-07-2005 11:52 AM
Re: Those cute little "WORK-SAFE" / "NOT WORK-SAFE" tags that people put in the Subject headers of their posts... Soapy Digital Photography 1 08-16-2004 12:07 PM
Re: Those cute little "WORK-SAFE" / "NOT WORK-SAFE" tags that people put in the Subject headers of their posts... Soapy Digital Photography 1 08-16-2004 06:24 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57