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 November 1st, 2005, 01:00 PM
Authorized User
 
Join Date: Sep 2005
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default Adding a <p> in text that has no xml tags

I have this XML File:

<prdpho>
     <a name="PDR" id"PRD01"></a>
     <h4>Product</h4>
     NOTE: These photos
     <i> More products <i/>
</prdpho>

As you notice in the 4th line i have something that says "NOTE: These photos". This line is NOT surrounded by XML Tags.

I CANNOT CHANGE THIS XML TO HAVE TAGS AROUND IT. I need to find a way to add the tags on the xslt and not on the xml.

For example i CANNOT change the XML FILE to have
<p> NOTE: These photos </p>
I CANNOT DO THAT...
I need to put the <p> using XSLT

I have no idea of how to do this, any solutions?

 
Old November 1st, 2005, 02:14 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

This should do the job:

<xsl:template match="*">
<xsl:copy><xsl:copy-of select="@*"/><xsl:apply-templates/></xsl:copy>
</xsl:template>

<xsl:template match="prdpho/text()[normalize-space()]">
  <p><xsl:copy-of select="."/>
</xsl:template>

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
<!DOCTYPE> Tags? kennethjaysone HTML Code Clinic 0 May 18th, 2007 01:39 AM
Question regarding the display of <a> tags in xml tajjyarden XSLT 1 March 21st, 2007 11:54 AM
Regular Expression to remove <table> </table> tags mathalete CSS Cascading Style Sheets 2 January 23rd, 2006 01:59 PM
Extracting text between <body> tags sumedha HTML Code Clinic 2 June 29th, 2005 02:37 PM
<style> tags in a <body> vs. <div> bcat BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 1 March 27th, 2005 08:50 AM





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