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 February 24th, 2011, 12:59 PM
Authorized User
 
Join Date: May 2007
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Default resolving entities

I have the following input:

<p>string of text &lt;sup&gt;&amp;#174;&lt;/sup&gt;<p>

I need to output only the text (and none of the html elements or entities):

<p>string of text</p>

Is there an easy way to resolve the entities and then grab the text() of the <p> element?
 
Old February 24th, 2011, 01:17 PM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Not in standard XSLT there isn't no. As far as the XSLT processor knows the text of the <p> element is just that, text.

If you are using Saxon and you know the inner text is valid XML then you could trying using saxon:evaluate() to process the inner text, then apply templates to only output child text() elements (e.g. <xsl:value-of select="saxon:evaluate(p)/child::text()"/> or similar.)
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old February 24th, 2011, 01:21 PM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Correction:

<xsl:value-of select="saxon:parse(concat('&lt;root&gt;',/p,'&lt;/root&gt;'))/root/child::text()"/>
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old February 24th, 2011, 01:27 PM
Authorized User
 
Join Date: May 2007
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am using Oxygen which uses Saxon. I tried to saxon:evaluate() and assigned the saxon namespace (http://icl.com/saxon), but I receive an error that it cannot find a matching 1-argument function.
 
Old February 24th, 2011, 01:30 PM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

I think for Saxon 9 the namespace is http://saxon.sf.net/, see http://www.saxonica.com/documentatio...ions/intro.xml
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
 
Old February 24th, 2011, 01:31 PM
Authorized User
 
Join Date: May 2007
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry, I had the namespace wrong and it works now.

Namespace: http://saxon.sf.net/

Thanks for your help!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Resolving classpath with ant <xslt> task igraham XSLT 9 September 26th, 2007 03:37 PM
resolving localhost phin Internet Information Services 5 February 26th, 2007 12:34 PM
Resolving entities when reading XML dmorin C# 0 September 25th, 2006 09:19 AM
Resolving a URL using XSLT vibin_nair XSLT 1 October 21st, 2003 03:53 AM





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