Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XPath expressions having namespaces

Reply
Thread Tools

XPath expressions having namespaces

 
 
gimme_this_gimme_that@yahoo.com
Guest
Posts: n/a
 
      04-20-2005
I have the following xml file and need some tips on xpath queries to
fetch the data.

I think I'm not handling namespaces correctly.

Here is xml file :


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

<epi:component build-version="Gold"
component-id="sss0005style0001"
component-type="Grids"
description="Grid that has 3 columns."
epi-build="105"
epi-version="7.1"
major-version="1"
minor-version="0"
title="Default Title"
xmlns:epi="http://www.epicentric.com/deployment">

<epi:required-component component-id="template0005"
component-type="Style Types"
major-version="7"
minor-version="1"
/>

<epi:detail>
<style-info apply-template-header="true"
description="A description."
friendly-id="sss_grid.default"
id="sss0005style0001"
is-system="false"
primary-filename="sss-grid-default.jsp"
processing-type="JSP_BASED"
template-default="false"
template-uid="template0005"
title="SPS Default Grid"
visible="true"
/>
</epi:detail>
</epi:component>


I've been testing the XPath queries using transforms via xalan. Here is
the xsl :


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlnssl="http://www.w3.org/1999/XSL/Transform"
xmlns:epi="http://www.epicentric.com/deployment">

<xsl:template match="/">
<xsl:value-of select="//style-info[@description]"/>
<xsl:value-of select="//epi:component[@build-version]"/>
</xsl:template>

</xsl:stylesheet>


Questions :

1. <xsl:value-of select="//style-info[@description]"/> doesn't return
anything.
What expression returns "A description" ?

Is there a fully qualified expression returning the same value? Like

"//epi:component/epi:detail/style-info[@description]".

2. <xsl:value-of select="//epi:component[@build-version]"/>
What expression returns "Gold" ?

 
Reply With Quote
 
 
 
 
Romin
Guest
Posts: n/a
 
      04-20-2005
1: //epi:component/epi:detail/style-info[@description]/@description --
returns "A description".

2: /epi:component[@build-version]/@build-version - returns "Gold".

In both the expressions that you have used -- you are searching for the
XML element that has the specified attribute - which is ok. All you
need to do is add the remaining part of the expression i.e. the
attribute value that you want to extract out.

 
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
XPath: selecting on namespaces kj XML 3 03-27-2010 10:23 AM
XPath and namespaces : a newbie question Omar XML 4 06-21-2005 04:41 AM
XPath and namespaces... Stefan Franke XML 6 01-03-2005 06:55 PM
XPath: efficiency in xpath expressions Tjerk Wolterink XML 1 11-13-2004 06:03 PM
XPath performance w/ Namespaces Jim XML 2 01-29-2004 10:58 PM



Advertisments