473,385 Members | 1,320 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

XSLT: Convert commercial at to its character entity

If I set as output method to HTML, it does what I want.

<html>
<body>
<p>
<a href="mailto:john_doe@example.com">John Doe</a>
</p>
</body>
</html>

If I set it to XHTML, it doesn't but I need to generate XHTML.

<?xml version="1.0" encoding="UTF-8"?>
<html>
<body>
<p>
<a href="mailto:john_doe&amp;#64;example.com">John Doe</a>
</p>
</body>
</html>

Using Xalan/J 2.5.2 for transformation if it matters...

people.xml
---------------------------------
<?xml version="1.0" encoding="UTF-8"?>

<people>
<person id="john">
<name>John Doe</name>
<email>jo******@example.com</email>
</person>
</people>
people.xsl
----------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="application/xml"?>

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

<xsl:output method="xhtml"/> <!-- CHANGE HERE TO HTML -->

<xsl:template match="people">
<html>
<body>
<xsl:apply-templates select="person"/>
</body>
</html>
</xsl:template>

<xsl:template match="person">
<xsl:variable name="protocol" select="'mailto'"/>
<xsl:variable name="username" select="substring-before(email,'@')"/>
<xsl:variable name="hostname" select="substring-after(email,'@')"/>

<p>
<a>
<xsl:attribute name="href">
<xsl:value-of select="$protocol"/>:<xsl:value-of
select="$username"/>
<!-- original try
<xsl:text>&amp;</xsl:text><xsl:text>#64;</xsl:text>
-->
<xsl:text disable-output-escaping="yes">
<![CDATA[@]]>
</xsl:text>
<xsl:value-of select="$hostname"/>
</xsl:attribute>
<xsl:value-of select="name"/>
</a>
</p>
</xsl:template>

</xsl:stylesheet>
Jul 20 '05 #1
1 3528
Anonymous <in******@hotmail.com> writes:
If I set as output method to HTML, it does what I want.

<html>
<body>
<p>
<a href="mailto:john_doe@example.com">John Doe</a>
</p>
</body>
</html>

If I set it to XHTML, it doesn't but I need to generate XHTML.

<?xml version="1.0" encoding="UTF-8"?>
<html>
<body>
<p>
<a href="mailto:john_doe&amp;#64;example.com">John Doe</a>
</p>
</body>
</html>


Why do you want to? <a href="mailto:jo******@example.com">John
Doe</a> is perfectly correct in both HTML and XHTML. The commercial at
sign does not have to be an entity reference.

--
Dean Tiegs, NE¼-20-52-25-W4
“Confortare et esto robustus”
http://telusplanet.net/public/dctiegs/
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Christian Roth | last post by:
Hello, when using this "identity" processing sheet: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" encoding="iso-8859-1" /> ...
6
by: Vincent Lefevre | last post by:
I would like to know if the base URI considered to resolve an unparsed entity defined by a relative URI should be the URI before or after its rewriting due to a possible catalog. Let's take an...
2
by: Andy Dingley | last post by:
I have some (somewhat ragged) HTML, and I wish to pre-process it with XSLT before putting it back onto the server. Throughout this HTML are many character entity references, such as "&ecaute;". ...
1
by: Mauro D. | last post by:
Hi guys, i'm trying to use xsl-fo to convert an html page to PDF. It's all ok but &egrave; &ograve; etc... I have read some howto over Internet that tell me about <!ENTITY> tag but it doesn't...
3
by: Bloody Viking | last post by:
Namaste, Y'all! I've got a problem I'm hoping one of you can solve. My stylesheet has the following bit of code: <xsl:template match="web|WEB"> <xsl:variable name="url"> <xsl:value-of...
11
by: cmay | last post by:
I am having this problem... Lets say that your source XML is formatted like this: <somenode> Here is some text Here is some more text </somenode> When to a <xsl:value-of select="somenode" /I...
8
by: Steven D'Aprano | last post by:
I have a string containing Latin-1 characters: s = u" and many more..." I want to convert it to HTML entities: result => "&copy; and many more..." Decimal/hex escapes would be...
1
by: basavaraj koti | last post by:
I need to show image using xslt Below provided in my xml and xslt. <?xml version="1.0" encoding="iso-8859-1"?> <?xml-stylesheet type="text/xsl" href="../xyz.xsl"?> <Grade class="03"...
1
by: qbp90x5lb | last post by:
I'm using an XSLT transform to output the element value contents from a simple XML file into a new .TXT file. Everything works fine except for certain XML files, when calling msxsl with the .xslt, I...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.