Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: XPath Queries not working correctly in Schema

From: Martin Honnen <mahotrash@-----.-->
To: NULL
Date: 4/5/2005 5:15:00 PM

rosemm wrote:

> i have a file which I get from a vendor. we are using a industry
> schema, hr-xml. however, I can't seem to get any XPath expresions to
> work when i receive the file. i think i have pinpointed the problem but
> now I need a solution.
> 
> I have the following template
> 
> <xsl:template match="//PersonName">
> 		<xsl:value-of select="normalize-space(FamilyName)"/>
> 		<xsl:text>,</xsl:text>
> 		<xsl:value-of select="normalize-space(GivenName)"/>
> 		<xsl:text>,</xsl:text>
> 		<xsl:value-of select="normalize-space(MiddleName)"/>
> 		<xsl:text>,</xsl:text>
> 		<xsl:value-of select="normalize-space(Affix)"/>
> 		<xsl:text>,</xsl:text>
> 	</xsl:template>
> 
> The beginning of my xml file looks like this (this is where the problem
> is)
> 
> <Enrollment xmlns="http://ns.hr-xml.org/2004-08-02"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://ns.hr-xml.org/2004-08-02
> Enrollment.xsd" creationDate="2005-03-31T11:47:26-06:00">
> 
> With this I get no data out of my file.

The elements are probably in the default namespace so to select them 
with an XPath 1.0 expression you need to bind a prefix to that namespace 
in the stylesheet e.g.
   <xsl:stylesheet
     xmlns:hr="http://ns.hr-xml.org/2004-08-02"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
then use that prefix in your XPath expression e.g.
   //hr:Person
or
   <xsl:value-of select="normalize-space(hr:FamilyName)"/>

See also
   <http://www.faqts.com/knowledge_base/view.phtml/aid/34022/fid/1753>

-- 

	Martin Honnen
	http://JavaScript.FAQTs.com/


transparent
Print
Mail
Digg
delicious
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