tuscany-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Millies, Sebastian" <sebastian.mill...@ids-scheer.com>
Subject AW: About Accessing DataObjects using XPath
Date Thu, 28 Mar 2013 14:33:31 GMT
Hello there,

what exactly is not working for you? When posting questions like this, it is always helpful
to include an error
message, perhaps even a stacktrace. (Also, I might add, it would be considered good form to
sign your mail
by name.)

Your example works for me, here's a test case demonstrating it:

        public void test()
                HelperContext scope = HelperProvider.getDefaultContext();
                DataFactory df = scope.getDataFactory();
                DataObject deliverGoods = df.create( "http://dataact.act.org", "deliverGoods"
                DataObject deliord = df.create( "http://dataact.act.org/xsd", "DeliverOrder"
                deliord.setDouble( "cost", 100 );
                deliverGoods.set( "deliord", deliord );

                DataObject sdo = deliverGoods.getDataObject( "deliord" );
                double actual = sdo.getDouble( "cost" );
                assertEquals( 100, actual, 0.0001 );

                double actualXPath = deliverGoods.getDouble( "deliord/cost" );  // <---
                assertEquals( 100, actualXPath, 0.0001 );

If you're getting a NullPointerException, perhaps you have not instantiated the "deliord"


----------------- 8< ------------------

Von: grovecai [mailto:grovecai@gmail.com]
Gesendet: Donnerstag, 28. März 2013 10:16
An: user@tuscany.apache.org
Betreff: About Accessing DataObjects using XPath


I have a DataObject as below and it's Type is defined in two schema with different targetNamespace.
Now  I want to access the "cost" property of the DataObject.The code is like that:
It doesn't work. What's proper xpath expression I should use?
Please help. Thanks!

<dat:deliverGoods xmlns:dat="http://dataact.act.org" xmlns:xsd="http://dataact.act.org/xsd">
      <xsd:address>buaa nmb g513</xsd:address>
      <xsd:goodname>The WS Haters Handbook</xsd:goodname>

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:ax26="http://dataact.act.org/xsd" targetNamespace="http://dataact.act.org">
    <xs:import namespace="http://dataact.act.org/xsd" />
    <xs:element name="deliverGoods">
                <xs:element minOccurs="0" name="deliord" nillable="true"
                    type="ax26:DeliverOrder" />

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    <xs:complexType name="DeliverOrder">
            <xs:element minOccurs="0" name="address" nillable="true"
                type="xs:string" />
            <xs:element minOccurs="0" name="buyer" nillable="true"
                type="xs:string" />
            <xs:element minOccurs="0" name="cost" type="xs:double" />
            <xs:element minOccurs="0" name="goodname" nillable="true"
                type="xs:string" />
            <xs:element minOccurs="0" name="id" type="xs:int" />

IDS Scheer Consulting GmbH
Geschäftsführer/Managing Directors: Arno Theiss, Ivo Totev
Sitz/Registered office: Altenkesseler Straße 17, 66115 Saarbrücken, Germany - Registergericht/Commercial
register: Saarbrücken HRB 19681

View raw message