Register  Login       Search  
Forum  
 
  
 
Forum  Forum     
 
SearchForum Home
  XML Lab Products  nxslt  Line breaks, ex...
 Line breaks, extra blank lines (nxslt v1)
 
eb44
1 posts
Joined
12/24/2006

Line breaks, extra blank lines (nxslt v1)
Posted: 24 Dec 06 9:47 AM (United States) Modified By eb44  on 12/24/2006 3:27:18 PM)
Using nxslt (v1) to transform XML to flat text. (Thank you for this utility.)
Problem: output file has line breaks in the data, and also many extra blank lines.
Other processors (e.g. msxml/msxlt, Architag's XRay) are not breaking or inserting the blank lines. It's as if the whitespace in between xslt template tags is being included in the output, and/or whitespace (like CRs) between xsl tags where there is no intervening text.
Have not yet tried nsxlt2.
Thank you for your help. --eb
--Followup: opton -xw eliminates this problem but I don't understand why it's needed. nsxlt seems to be transforming all input nodes including whitespace like CR/LF that are between the source xml tags.
My xslt is matching every single tag, and anything that I don't want in the output is being suppressed as follows: (using square brackets to avoid angle-brack translation problems).
[xsl:template match="*"][/xsl:template].
This should eliminate unwanted source data from getting processed, and so I don't understand why there are any whitespace text nodes that would otherwise be in the output for -xw to eliminate.
Thanks again --eb
earlNameless
3 posts
Joined
1/16/2007

Re: Line breaks, extra blank lines (nxslt v1)
Posted: 17 Jan 07 7:17 PM (N/A)
Not exactly sure if this is the case, but it might be (somewhat technical).

In Xslt when you specify "*" as the match for a template, that is equivalent to "child::*" which is different from "child::node()". "child::*" selects only elements, but "child::node()" selects any child type (elements, attributes, text, etc). Therefore, depending on what your xml document contains, and on what your [xsl:apply-templates/] tags select, you could be applying templates to any child node.

Lets say your xml code contains:
[p]hello [b]world[/b][/p]
Then if you do [xsl:apply-templates/], the elements to which templates will be applied will be:
- "hello"
- [b]world[/b]
The "hello" although not an element is a node, and therefore templates will be applied to it, and by default the template that is applied to it (unless overriden) is to output the text (in this case to output "hello").

To override this so that text between your tags (text that is used for formatting) is not processed, add the following template to your xslt:
[xsl:template match="text()"/]
  XML Lab Products  nxslt  Line breaks, ex...
Forum Home  Search