473,320 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

transformation in text-mode

Hi!

I have the following xml-node:

<docu>
<p>Sample: <b>bold</b></p>
<p>and text in <i>italic</i></p>
</docu>

I need to create a text-file, so I set the output-mode to text.
In a docu-node you can write normal text and additionally html-tags.

In the text-file I should output that:

"<p>Sample: <b>bold</b></p><p>and text in <i>italic</i></p>"

i.e. compress text between <docu> and </docu> in a single line.
I wrote this template - but it dont't work. The html-tags are filtered
out and the linebreak is still there.

<xsl:template match="docu">
<xsl:copy-of select="."/>
</xsl:template>

In html-mode the html-tags will be copied.
How can I do this??

Thanx for help!
Jürgen
Jul 20 '05 #1
2 2852
By definition the setting method="text" in xsl:output should only output
the contents of the text nodes in the result tree:

"16.3 Text Output Method
The text output method outputs the result tree by outputting the
string-value of every text node in the result tree in document order without
any escaping."

http://www.w3.org/TR/xslt#section-Text-Output-Method



"Jürgen Holly" <ju***********@immorent.at> wrote in message
news:2b**************************@posting.google.c om...
Hi!

I have the following xml-node:

<docu>
<p>Sample: <b>bold</b></p>
<p>and text in <i>italic</i></p>
</docu>

I need to create a text-file, so I set the output-mode to text.
In a docu-node you can write normal text and additionally html-tags.

In the text-file I should output that:

"<p>Sample: <b>bold</b></p><p>and text in <i>italic</i></p>"

i.e. compress text between <docu> and </docu> in a single line.
I wrote this template - but it dont't work. The html-tags are filtered
out and the linebreak is still there.
By definition the setting method="text" in xsl:output should only output
the contents of the text nodes in the result tree:

"16.3 Text Output Method
The text output method outputs the result tree by outputting the
string-value of every text node in the result tree in document order without
any escaping."

http://www.w3.org/TR/xslt#section-Text-Output-Method

Therefore, if you need the element nodes copied, you must node use
method="text".

<xsl:template match="docu">
<xsl:copy-of select="."/>
</xsl:template>

In html-mode the html-tags will be copied.
How can I do this??

You must read all about whitespace nodes processing in xslt.

The above xsl:copy-of in your code copies the subtree with root the current
node ("docu") and this includes all of its whitespace-only descendents.

In case you do not need to process whitespace only nodes in your document,
you can use:

<xsl:strip-space elements="*"/>

This specifies that the whetespace-only text nodes of all elements are to be
striped.

In case you only need to ignore whitespace-only children of specific
elements and presereve the whitespace-only children for others, then you
must explicitly specify the value of the "elements" attribute of
xsl:strip-space as a blank-separated list of element names, whose
children-whitespace-only-text nodes are to be stripped.

=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL


Jul 20 '05 #2
if the majority of your output file is xml (or html) and only a few bits
aren't, you can use disable-output-escaping on only those sections which
need text mode output. otherwise you will need to do something like this:

<xsl:template match="docu//*">
&lt;<xsl:value-of
select="name()">&gt;<xsl:apply-templates/>&lt;/<xsl:value-of
select="name()">&gt;
</xsl:template>

however, your other problem is you are not processing whitespace properly.
If you want to remove whitespace nodes from the result tree you will need to
exclude them when calling apply-templates. try something like

<xsl:apply-templates select="*|@*">

which will only select sub-elements and attributes, rather than the default
which selects all child nodes (sorry - neither of these two examples are
tested)

Andy

"Jürgen Holly" <ju***********@immorent.at> wrote in message
news:2b**************************@posting.google.c om...
Hi!

I have the following xml-node:

<docu>
<p>Sample: <b>bold</b></p>
<p>and text in <i>italic</i></p>
</docu>

I need to create a text-file, so I set the output-mode to text.
In a docu-node you can write normal text and additionally html-tags.

In the text-file I should output that:

"<p>Sample: <b>bold</b></p><p>and text in <i>italic</i></p>"

i.e. compress text between <docu> and </docu> in a single line.
I wrote this template - but it dont't work. The html-tags are filtered
out and the linebreak is still there.

<xsl:template match="docu">
<xsl:copy-of select="."/>
</xsl:template>

In html-mode the html-tags will be copied.
How can I do this??

Thanx for help!
Jürgen

Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Sergio del Amo | last post by:
Hi, I use the xslt functions provided by php. I am running in my computer the package xampp(www.apachefriends.org) which includes php/apache/mysql .. In this package the php includes the sablotron...
3
by: pradeep gummi | last post by:
I have an XML FILE that is to be converted to Plain Text using an XSL file. Since I just want plain text, I do not want to set any root element during transformation.And if I do not any root...
4
by: Mike Conmackie | last post by:
Hi Folks, I've probably omitted something very basic but I have no idea what it might be. The results of my transformation _should_ be an xml file but all I get is the xml declaration...
1
by: Andrew Connell | last post by:
I have an XML document and an XSLT transformation sheet. My first issue is that my XML file won't load into the XPathDocument object. However, when I use an obsolete transformation method where I...
2
by: TomekR | last post by:
Hello ! I was developing xslt sheet lately and - experimenting - I made mistake resulting in that, the effect of the transformation is not well-formed xml document. I made these tests using...
7
by: Bilal | last post by:
Hello, I'm attempting to "populate" an template XML file with some data using identity transform (approach suggested by Joe K.; Thanks! :-) and have come across some strange behaviour using...
2
by: HendrikLeder | last post by:
Hello everybody :-) Next year I`ll write my diploma in computer science for business (It`s a degree in Germany) and I`ve some questions about the topic. The diploma will handle about refactoring...
18
by: R. P. | last post by:
I wonder how to indicate in a stylesheet that character entities in an element are not to be transformed as would be the case in XML-to-XML transforms. I want to keep those &amp; &quot; and other character...
14
by: Thomas Bauer | last post by:
Hello, I search a example like that. (1,0,0,1,4,5 ) -- moving (1,0,0,1,0,0 ) -- normal matrix (-1,0,0,1,0,0 ) -- Mirror Y-Axis (0,-1,0,1,0,0 ) -- Mirror X-Axis I caluculate all in mm.
2
by: abhimanyu singh | last post by:
i m facing a serious probs now a days............ its seems easy but for me i found it difficult......... i want to do transformation usig xsl and xml(adding parameter). for IE its working fine...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.