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 September 4th, 2006, 04:20 AM
Authorized User
 
Join Date: Sep 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to nadavvin
Default How can I take HTML content in XSLT?

<xsl:value-of> tag is ignore from sub tag.

For example I have this XML:

Code:
 <?xml version="1.0"?>
<root>
          <content>
                  [u]Hello World</u>
                   hi all
          </content>
</root>
How do I get all the content of content?
The <xsl:value-of> is get only "hi all".

Thanks for your help
Nadav

 
Old September 4th, 2006, 04:43 AM
Authorized User
 
Join Date: Sep 2006
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Nadav,

Try this link ...

http://www.jenitennison.com/xslt/merging-docs.xml

Jeni explains the various possibilities very well.

I hope that helps? :-)

Cheers,
Alan.

 
Old September 4th, 2006, 05:08 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

The instruction

<xsl:value-of select="content"/>

with root as your context node will return "Hello World hi all" plus some whitespace.

If you want to retain the element node, use <xsl:copy-of>



Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old September 4th, 2006, 08:58 AM
Authorized User
 
Join Date: Sep 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to nadavvin
Default

Thanks, It's work!


<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<xsl:copy-of select="/root/content" />

</xsl:template>
</xsl:stylesheet>

 
Old September 6th, 2006, 02:44 AM
Authorized User
 
Join Date: Sep 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to nadavvin
Default

The problem is that the content is not HTML tag and copy-of is copy it also.

Is there a way to copy the content of a tag without the tag itself?

 
Old September 6th, 2006, 03:07 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Can you show an example of your output given the example file above?
Either you want the elements as well or you don't, or you want to replace them with new ones, which is it?

--

Joe (Microsoft MVP - XML)
 
Old September 6th, 2006, 03:25 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I guess that by the content of a tag you mean the stuff between the tags. Correctly speaking, given <a>xyz</a> there are two tags, whose content is "a" and "/a" respectively. It's better to talk about element nodes and their children - the input to an XSLT transformation is a tree of nodes, not a string containing angle brackets. Using the right terminology will help you find the right information.

If you want to copy the children of an element node, and that element is the current context node, use <xsl:copy-of select="child::node()"/>

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old September 6th, 2006, 09:18 AM
Authorized User
 
Join Date: Sep 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to nadavvin
Default

If you want to copy the children of an element node, and that element is the current context node, use <xsl:copy-of select="child::node()"/>

yes this is what I want.
Sorry for the misunderstood.

Nadav






Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing attribute name into XSLT to pull content Naughtytrini XSLT 2 March 26th, 2008 03:06 PM
saving html content as xml data using javascript ravillasubhash Javascript How-To 0 May 23rd, 2007 08:11 AM
Displaying textarea content to html table keithc Pro PHP 2 December 1st, 2006 03:12 AM
Include file in HTML content itHighway Classic ASP Basics 1 July 25th, 2005 05:44 PM
Content-type = text/html tarran C# 3 December 5th, 2004 08:36 AM





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