Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

XPath - namespaces

$
0
0

I've been using XML/XPath since Eve was a rib.  So I know that most people will answer this with , "It can't be done."  However, I really need to find a way for this to work.

I'm working on a project that is using OAGIS BOD documents as a messaging format.  Without getting too deeply into the weeds, I'll give an example of a document and what my needs are:

<?xml version="1.0" encoding="UTF-8"?><NotifyTimeCard 
			systemEnvironmentCode="Production" 
			releaseID="3.2"  
			languageCode="en-US" 
			xsi:schemaLocation="http://www.hr-xml.org/3  ../Developer/BODs/NotifyTimeCard.xsd" 
			xmlns="http://www.hr-xml.org/3" 
			xmlns:oa="http://www.openapplications.org/oagis/9" 
			xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><oa:ApplicationArea><oa:CreationDateTime>2009-05-17T11:09:02.01Z</oa:CreationDateTime><oa:BODID>PC2009-31-13-016</oa:BODID></oa:ApplicationArea><DataArea><oa:Notify><oa:ActionCriteria><oa:ActionExpression actionCode="Modified">/NotifyTimeCard/DataArea/TimeCard/TimeCardReportedItem[ID="1"]</oa:ActionExpression><oa:ChangeStatus><oa:ReasonCode>Corrected GL Account No.</oa:ReasonCode></oa:ChangeStatus></oa:ActionCriteria></oa:Notify><TimeCard majorVersionID="1" minorVersionID="0"><DocumentID schemeAgencyID="StaffingCoInc.com">99999111888</DocumentID><TimeCardReportedItem><ID>1</ID><TimeReportedStatusCode>Corrected</TimeReportedStatusCode><CostAllocation><AllocationID schemeID="GL Account No.">14-00054</AllocationID><AllocationPercentage>55</AllocationPercentage></CostAllocation><CostAllocation><AllocationID schemeID="GL Account No.">14-00032</AllocationID><AllocationPercentage>45</AllocationPercentage></CostAllocation><TimeInterval><ID>Mon</ID><FreeFormEffectivePeriod><StartDate><FormattedDateTime>2009-05-04</FormattedDateTime></StartDate><oa:Duration>PT8H</oa:Duration></FreeFormEffectivePeriod></TimeInterval></TimeCardReportedItem></TimeCard></DataArea></NotifyTimeCard>

A BOD can contain any number of actions (verbs) that have to be performed on any number of objects (nouns).  I the case of this document, a TimeCard item has been modified.  The processing works as:

1) Find the actions you need to perform  - The Action Code is "Modified"

2)  Find the nouns that needs to have that action perfoemed - represented by the result of the xpath expression /NotifyTimeCard/DataArea/TimeCard/TimeCardReportedItem[ID="1"]

3) Process those 2 items in accordance with your domain

So, my problem is that the xpath expression does not have any namespaces in it, whereas the overall document does.  I know that with the .NET implementation of XPath 1.0 you have to use a namespace manager and the xpath expression has to use aliases if you're using namespaces.  However, many people are currently using the OAGIS BOD structure.  Biztalk Server is able to evaluate these namespace-less xpath expresions so there is something somewhere in the Microsoft technology stack that will allow this to work.

I've thought about possible re-writing the xpath expression, injecting aliases for the default namespace, but there is no garuntee that all of the elements are in the same namespace.  it really needs to just ignore them. This is possible in accordance to the XPath 2.0 spec, which .NET does not support.

I'm in the process at looking at SAXON since it supports 2.0, but I didn't want to start getting too far into the weeds if someone else has figured out a technique to manage this.  Any ideas?



Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>