Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| Search | Today's Posts | Mark Forums Read
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
  #1 (permalink)  
Old November 21st, 2005, 10:48 PM
Authorized User
 
Join Date: Oct 2005
Location: , , Philippines.
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default Entity Question

Is there a function in xslt that test whether a string is an entity or in a string there is an entity? Because I want to tag this entites.
Thanks.

  #2 (permalink)  
Old November 22nd, 2005, 05:06 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

XML entity references are expanded by the XML parser (that is, replaced by their replacement text) before the XSLT processor gets to see them. The data model defining what XSLT sees does not include entities. If you want to manipulate XML at this physical level you need a lower-level tool than XSLT.

One trick that's sometimes used is to modify the entity replacement text to include element tags, which are then visible to the XSLT processor.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
  #3 (permalink)  
Old November 24th, 2005, 01:33 AM
Authorized User
 
Join Date: Oct 2005
Location: , , Philippines.
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I see... Thanks.

  #4 (permalink)  
Old November 26th, 2005, 12:45 AM
Authorized User
 
Join Date: Apr 2005
Location: Chennai, Tamil Nazdu, India.
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is xml file

<!DOCTYPE web-app SYSTEM "file:///entities.dtd">
<web-app id="WebApp_ID" version="2.4">
    <display-name>&lt;&eacute;
    hello</display-name>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>
</web-app>



in the XSL file
?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="text" version="1.0" encoding="UTF-8" indent="yes"/>
    <xsl:template match="/">
            <xsl:for-each select="web-app/*">
                           <xsl:if test="name(.)='display-name'">
                                       <xsl:if test="contains(text(), '#233;')">
                                                   <xsl:text>yes</xsl:text>
                                       </xsl:if>
                           </xsl:if>
            </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>


  #5 (permalink)  
Old November 30th, 2005, 05:22 AM
Authorized User
 
Join Date: Oct 2005
Location: , , Philippines.
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for the help but I need it to be generic, that is any case of entity.

  #6 (permalink)  
Old December 1st, 2005, 08:18 AM
Authorized User
 
Join Date: Apr 2005
Location: Chennai, Tamil Nazdu, India.
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have given only the sample. if you want to be generic then use regular expressions of xslt 2.0


  #7 (permalink)  
Old December 5th, 2005, 05:28 AM
Authorized User
 
Join Date: Oct 2005
Location: , , Philippines.
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i have tried to use it but as michael have said, the dtd has already been parsed so there will be no match for the entities.



Similar Threads
Thread Thread Starter Forum Replies Last Post
Entity Conversion vengatatindia Word VBA 0 February 15th, 2008 05:52 AM
character entity into numeric character entity srkumar XSLT 1 November 22nd, 2007 04:53 AM
entity conversion orlyyefet XSLT 3 July 29th, 2007 03:14 PM
Sum up value of all entity ksafong XSLT 2 October 28th, 2006 03:47 AM
Difference between Entity and Entity type arshad mahmood C++ Programming 0 May 8th, 2004 12:34 AM





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