Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


XSLT Stylesheet test for special character

From: Jack Bush <netbeansfan@-----.---.-->
To: xml-dev@-----.---.---
Date: 1/21/2009 2:04:00 AM
Hi All,
 
I need some assistance to compare a string value of an node before deciding on what child element/attribute to extract from. Here are the detail as follows:
 
<?xml version="1.0" encoding="UTF-8" ?> 
<!DOCTYPE html (View Source for full doctype...)> 
- <html xmlns="http://www.w3.org/1999/xhtml" xmlns:html="http://www.w3..org/1999/xhtml">
- <head>
- <body 
........
- <div id="container">
+ <div id="header">
<div id="postmark" /> 
- <div id="content">
+ <div id="as1">
....... 
<h1>Employee Detail</h1> 
- <p>
<strong>Firstname:</strong> 
<a shape="rect" title="Firstname of employee">John</a> 
</p>
- <p>
<strong>Surname:</strong> 
<a shape="rect" title="Lastname of employee">Smith</a> 
</p>
- <p>
<strong>Date of birth:</strong> 
12/01/1932 
</p>
- <p>
<strong>Sex:</strong> 
M 
</p>
- <p>
<strong>Interest:</strong> 
<br clear="none" /> 
Tennis 
<br clear="none" /> 
Movie
<br clear="none" /> 
.....
 
 
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="ns">

( 1 ) <xsl:template match="/">
( 2 ) <employee>
( 3 ) <xsl:for-each select="/ns:html/ns:body/ns:div[@id='content']/ns:p">
( 4 ) <xsl:value-of select="ns:strong"/>
( 5 ) <xsl:choose>
( 6 ) <xsl:when test="Firstname:">
( 7 ) <firstname><xsl:value-of select="."/></firstname>
( 8 ) </xsl:when>
( 9 ) <xsl:otherwise>
( 10 ) <firstname>Unknown</firstname>
( 11 ) </xsl:otherwise> 
( 12 ) </xsl:choose>
( 13 ) </xsl:for-each>
( 14 ) </employee>
( 15 ) </xsl:template>
( 17 ) 
( 18 ) </xsl:stylesheet>
 
I have no problem with test="Firstname" (line 6) but the ":" appears to be a special character that needs additional syntax (possible escape character) to pick up "Firstname:" together.
 
The error message has something like: Invalid QName on line 6 of stylesheet....
Your assistance would be very much appreciated.
Thanks,
Jack




      
Stay connected to the people that matter most with a smarter inbox. Take a look.


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent