Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 13th, 2010, 06:01 AM
Authorized User
 
Join Date: Jul 2010
Posts: 27
Thanks: 6
Thanked 0 Times in 0 Posts
Default redundant text in output xml

I have problem with my transformation file.
For the target file, after success in putting the text inside the tag. It appears the redundancy text after tags for text output. For example:

<person id="122345" name "Assand"> Assan
<hair color="red" style="curly">
<measure long="0.5 m"/>
</hair> Assanredcurly0.5 m
</person>
------
I don't know what is the problem?
I got the suggestion like: <xsl:template match="text()" mode="#all" />
And it works.
I want to know: what is the problem with the text output? Is there any solution to deal with problem without use <xsl:template match="text()" mode="#all" />.
 
Old August 13th, 2010, 06:09 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Thumbs up

Post the input xml, xslt code and the needed output xml.
__________________
Rummy
 
Old August 13th, 2010, 06:11 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

There are two built in template in XSLT. The first processes all child elements for any element that does not have a specific template:

Code:
<xsl:template match="*">
<xsl:apply-templates />
</xsl:template>
The second output all text from text nodes:

Code:
<xsl:template match="text()">
<xsl:value-of select="."/>
</xsl:template>
These two templates apply whatever values you have for mode.

Without seeing your XSLT and input XML it is hard to say anything more specific.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old August 13th, 2010, 06:55 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>I don't know what is the problem?
>I got the suggestion like: <xsl:template match="text()" mode="#all" />
>And it works.

You'd be good as a crossword-puzzle compiler. Give people just enough information to solve the problem, but no more. Don't show them your code (that would make debugging too easy), just tell them a change to the code that makes it work.

Well, the fact that adding the above rule eliminates the unwanted text means that the unwanted text is coming from the built-in template for text nodes, which means that somewhere you are doing an apply-templates that selects text nodes; or it might be an apply-templates that selects elements node ancestors of those text nodes if there isn't a specific template rule to process those elements. Beyond that, without your code, we can't tell.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Trailing blanks for 'text' output Neal XSLT 5 May 29th, 2008 06:25 AM
TEXT OUTPUT IN WINDOWS suman_16 XSLT 1 January 24th, 2008 06:09 AM
Output to text bonekrusher XSLT 4 November 25th, 2007 01:06 PM
XSL:output method="text" Pankaj C XSLT 4 August 2nd, 2007 10:05 AM
text output problems dextermagnific XSLT 1 August 10th, 2006 12:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.