[RUS-WG] A Comment About XPath and Namespaces in RUS

Gilbert Netzer noname at pdc.kth.se
Mon Apr 2 04:06:07 CDT 2007


Hi everybody,

I want to pick up the thread of discussion that is going on about namespace 
   mappings an XPath expressions, see the cut our below from the document 
on the GridForge to provide context:

Given the following UR document (actually sample UR 1 from the GRD.098):

<JobUsageRecord xmlns="http://schema.ogf.org/urf/2003/09/urf"
   xmlns:urf="http://schema.ogf.org/urf/2003/09/urf"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://schema.ogf.org/urf/2003/09/urf
file:/Users/bekah/Documents/GGF/URWG/urwg-schema.09.xsd">
<RecordIdentity
urf:recordId="http://www.emsl.pnl.gov/mscf/colony/PBS.1234.
0" urf:createTime="2003-08-13T18:56:56Z" />
<JobIdentity>
<LocalJobId>PBS.1234.0</LocalJobId>
</JobIdentity>
<UserIdentity>
<LocalUserId>scottmo</LocalUserId>
</UserIdentity>
<Charge>2870</Charge>
<Status>completed</Status>
<Memory urf:storageUnit="MB">1234</Memory>
<ServiceLevel urf:type="QOS">BottomFeeder</ServiceLevel>
<Processors>4</Processors>
<ProjectName>mscfops</ProjectName>
<MachineName>Colony</MachineName>
<WallDuration>PT1S</WallDuration>
<StartTime>2003-08-13T17:34:50Z</StartTime>
<EndTime>2003-08-13T18:37:38Z</EndTime>
<NodeCount>2</NodeCount>
<Queue>batch</Queue>
<Resource urf:description="quoteId">1435</Resource>
<Resource urf:description="application">NWChem</Resource>
<Resource
urf:description="executable">nwchem_linux</Resource>
</JobUsageRecord>

The obvious way to select it using XPath is the the expression
(for example, matching by recordId)

/JobUsageRecord[RecordIdentity/@recordId="http://www.emsl.pnl.gov/mscf/colony/PBS.1234.0"]

Now the problem is that here all the element and attribute names must not 
be in a namespace, so the expression will not select the given record. To 
make it work namespaces have to be included meaning the expression would 
have to look like this (the ns1: prefix was chosen on purpose of 
illustration, it could have also been urf: ):

/ns1:JobUsageRecord[ns1:RecordIdentity/@ns1:recordId="http://www.emsl.pnl.gov/mscf/colony/PBS.1234.0"]

And now some mapping from the prefix ns1 to the URI 
http://schema.ogf.org/urf/2003/09/urf needs to be provided so that the 
prefix can be resolved to a qualified name. In the XPath specification 
these mapping seem to be given by the static context (see 
http://www.w3.org/TR/xpath20/#static_context) which is coming from the host 
environment (see Processing Model). There is also nothing in XPath that 
would let you specify a mapping between a namespace prefix and the 
corresponding URI. You can also not directly write the URIs in the expression.

In XSLT (http://www.w3.org/TR/xslt20/), it seems that the available 
namespace mappings (prefix->URI) are taken from the in-scope mappings of 
the surrounding element of the stylesheet, so you would add a
xmlns:ns1="http://schema.ogf.org/urf/2003/09/urf" to the element containing 
the above XPath and everything is fine.

I would suggest that RUS goes along the same track and says that every 
mapping that is in scope for the XML element that immediately contains the 
XPath expression (this is its direct parent), is available in the XPath 
expression. That should provide a well-defined set of mappings that the 
user can provide along with her XPath expression.

I hope that did clarify what I was suggesting.

Best Regards
Gilbert Netzer



--- Cut from the document
[Comment 2]

* It’s also suggested that a clarification should be inserted into the 
specification about how namespace mappings are passed to the Path
expressions used as search terms. He suggests that all namespace mappings 
that are in scope for the surrounding XML element should be available in 
the XPath expression.” [Gilbert]

Evaluation
* I think they are automatically accessible with XPath (namespace mappings 
are simply attributes of the root element, aren't they?), but I might be 
wrong.” [Rosario]

* I don’t quite understand what the ‘namespace-mapping’ here refers to. 
XPath expressions in RUS specification are used for orientation to a 
context node of usage records, which should be one of the usage properties 
defined in OGF-UR schema and thus shares common namespace, 
‘http://schema.ogf.org/urf/2003/09/urf”. In this sense, I don’t think the 
necessity to provide namespace mapping. Besides that, the XPath parameter 
take the String format and could be in normative format with namespace 
explicitly associated with elements or in normal format without namespace 
and leaving the implementation to add namespace during transaction” [Xiaoyu]

SourceForge Administrator wrote:
> Project: RUS-WG
> Folder: Version 1.0
> 
> doc14370: Consodiated Comments on draft-17 & 19
> 
> Description: Please feel free to add your own comments and evaluations
> 
> Created on 04/01/2007 by Xiaoyu Chen
> 
> 
> To view the Document, go to:
> http://forge.gridforum.org/sf/go/doc14370
> 



More information about the rus-wg mailing list