Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 30th, 2011, 07:42 PM
Authorized User
 
Join Date: Feb 2007
Posts: 51
Thanks: 3
Thanked 0 Times in 0 Posts
Default xpath query (filter) syntax problem?

Hello,
I am using a xml-based subscribe-notify framework called SES (OpenGIS Sensor Event Service). It has an xpath-based filtering capability to appropriately match a subscription with notifications.

Based on a subscription of:

Code:
 
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2">
    <soap:Header>
        <wsa:To>http://localhost:8080/ses-main-1.0-SNAPSHOT/services/SesPortType</wsa:To>
        <wsa:Action>http://docs.oasis-open.org/wsn/bw-2/NotificationProducer/SubscribeRequest</wsa:Action>
        <wsa:MessageID>uuid:4e595160-185a-9b3c-3eb6-592c7c5b0c7a</wsa:MessageID>
        <wsa:From>
            <wsa:Address>http://www.w3.org/2005/08/addressing/role/anonymous</wsa:Address>
        </wsa:From>
    </soap:Header>
    <soap:Body>
        <wsnt:Subscribe>
            <wsnt:ConsumerReference>
                <wsa:Address>http://localhost:8082/</wsa:Address>
            </wsnt:ConsumerReference>
            <wsnt:Filter>
                <wsnt:MessageContent Dialect="http://www.w3.org/TR/1999/REC-xpath-19991116">//om:procedure@xlink:href='urn:eu:fp7:genesis:procedure:aircraft_A'</wsnt:MessageContent>
            </wsnt:Filter>
        </wsnt:Subscribe>
    </soap:Body>
</soap:Envelope>
where you see the filter (in bold: wsnt:Filter). I was thinking that xpath expression I defined would have resolved to "true" for a notification with the following structure:
Code:
 
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2">
    <soap:Header>
        <wsa:To>http://localhost:8080/ses-main-1.0-SNAPSHOT/services/SesPortType</wsa:To>
        <wsa:Action>http://docs.oasis-open.org/wsn/bw-2/NotificationConsumer/Notify</wsa:Action>
        <wsa:MessageID>uuid:1b4d3025-f80a-a5b6-aa37-864c47fa1a7e</wsa:MessageID>
        <wsa:From>
            <wsa:Address>http://www.w3.org/2005/08/addressing/role/anonymous</wsa:Address>
        </wsa:From>
    </soap:Header>
    <soap:Body>
        <wsnt:Notify>
            <wsnt:NotificationMessage>
                <wsnt:Topic Dialect="http://docs.oasis-open.org/wsn/t-1/TopicExpression/Simple"> 
	IntegratedHealthIndex
                </wsnt:Topic>
                <wsnt:Message>
                    <om:Observation gml:id="o211" xmlns:om="http://www.opengis.net/om/1.0" xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sa="http://www.opengis.net/sampling/1.0" xsi:schemaLocation="http://www.opengis.net/om/1.0 http://schemas.opengis.net/om/1.0.0/om.xsd http://www.opengis.net/sampling/1.0 http://schemas.opengis.net/sampling/1.0.0/sampling.xsd">
      <om:samplingTime>
        <gml:TimeInstant xsi:type="gml:TimeInstantType">
          <gml:timePosition>2009-05-30T01:00:00+02:00</gml:timePosition>
        </gml:TimeInstant>
      </om:samplingTime>
      <om:procedure xlink:href="urn:eu:fp7:genesis:procedure:aircraft_A"/>
      <om:observedProperty xlink:href="urn:eu:fp7:genesis:property:position"/>
      <om:featureOfInterest>
        <sa:SamplingPoint gml:id="Pos_A_01">
          <gml:name>Aircraft_B_Position</gml:name>
          <sa:sampledFeature xlink:href=""/>
          <sa:position>
            <gml:Point>
              <gml:pos srsName="urn:ogc:crs:epsg:4326">-119.853 40.817</gml:pos>
            </gml:Point>
          </sa:position>
        </sa:SamplingPoint>
      </om:featureOfInterest>
      <om:result>position</om:result>
    </om:Observation>
                </wsnt:Message>
            </wsnt:NotificationMessage>
        </wsnt:Notify>
    </soap:Body>
</soap:Envelope>
and forwarding the corresponding notification to the appropriate consumer.
Just as a sanity check, I can indeed get the notification forwarded appropriately when I make the filter wide-open using:
Code:
 <wsnt:Filter>
                <wsnt:MessageContent Dialect="http://www.w3.org/TR/1999/REC-xpath-19991116">*</wsnt:MessageContent>
            </wsnt:Filter>
however, my slightly-more-constrained filter is generating no forwarded notifications. I am hoping someone might see something obviously wrong with my xpath expression, or else be able to give me some tips. Any reply is appreciated. Thank you!
 
Old January 31st, 2011, 03:15 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

That isn't a valid xpath expression. You want the predicate to be in square brackets:

Code:
//om:procedure[@xlink:href='urn:eu:fp7:genesis:procedure:aircraft_A']
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old January 31st, 2011, 05:04 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Check the SES documentation to see how it handles namespace prefixes in XPath expressions. Your expression has a prefix "om" that isn't bound to any namespace in the context of the expression. It might take the namespace bindings from the source document, in which case you're OK - or it might not.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old January 31st, 2011, 09:11 AM
Authorized User
 
Join Date: Feb 2007
Posts: 51
Thanks: 3
Thanked 0 Times in 0 Posts
Default

thanks for replies thus far. I tried just now:
Code:
//om:procedure[@xlink:href='urn:eu:fp7:genesis:procedure:aircraft_A']
but I still am receiving no response.

Also, based upon what mhkay said about namespace prefixes, I was wondering whether a simpler expression like:
Code:
<wsnt:Filter>
                <wsnt:MessageContent Dialect="http://www.w3.org/TR/1999/REC-xpath-19991116">//@xlink:href='urn:eu:fp7:genesis:procedure:aircraft_A'</wsnt:MessageContent>
            </wsnt:Filter>
but this did not work either. Grateful for any other ideas! Thanks!
 
Old February 1st, 2011, 11:57 AM
Authorized User
 
Join Date: Feb 2007
Posts: 51
Thanks: 3
Thanked 0 Times in 0 Posts
Default

yes it was the fact that the xpath processor didn't have the bindings for the om and xlink namespaces. All works now. Thanks!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Xpath Query Problem Muhammad Kashan Khan XML 1 July 11th, 2009 07:16 AM
XPST0081: XPath syntax error ... with Saxon markus2000 XSLT 3 June 22nd, 2006 09:53 AM
Syntax help with string-length and XPath EstherMStrom XSLT 1 February 9th, 2005 08:02 PM
xpath syntax problem nrane26 XSLT 1 January 22nd, 2005 01:25 PM
Query syntax problem mateenmohd Access 2 October 12th, 2004 11:33 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.