Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XSLT: Convert commercial at to its character entity

Reply
Thread Tools

XSLT: Convert commercial at to its character entity

 
 
Anonymous
Guest
Posts: n/a
 
      03-05-2004
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>(E-Mail Removed)</email>
</person>
</people>


people.xsl
----------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="application/xml"?>

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

<xslutput 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>
 
Reply With Quote
 
 
 
 
Dean Tiegs
Guest
Posts: n/a
 
      03-06-2004
Anonymous <(E-Mail Removed)> 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="(E-Mail Removed)">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/
 
Reply With Quote
 
 
 
 
Anonymous
Guest
Posts: n/a
 
      03-07-2004
In article <(E-Mail Removed)>,
Dean Tiegs <(E-Mail Removed)> wrote:

> Anonymous <(E-Mail Removed)> 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="(E-Mail Removed)">John
> Doe</a> is perfectly correct in both HTML and XHTML. The commercial
> at sign does not have to be an entity reference.


Ever heard of email harvesting? Page(s) would be on very public
site and we get enough SPAM as is. Obfuscating email addresses
by character entity conversion is an effective means of hiding in
plain sight.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Its a bird, its a plane, no ummm, its a Ruide thunk Ruby 1 03-30-2010 11:10 AM
Entity, problem with entity key ThatsIT.net.au ASP .Net 1 09-07-2009 02:20 AM
Entity Framework - Reassigning child entity's parent Norm ASP .Net 3 07-06-2009 07:28 PM
How to relate a SQL based entity with an Object based entity in Entity Framework markla ASP .Net 1 10-06-2008 09:42 AM
Entity Name or Entity Number? Samuel van Laere HTML 4 02-24-2007 10:11 PM



Advertisments