Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 320544 - XPath mapping problem
Summary: XPath mapping problem
Status: CLOSED INVALID
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-21 15:06 EDT by Blaise Doughan CLA
Modified: 2022-06-09 10:21 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Blaise Doughan CLA 2010-07-21 15:06:48 EDT
Given the following object model:

package forum21;

import javax.xml.bind.annotation.XmlRootElement;

import org.eclipse.persistence.oxm.annotations.XmlPath;

@XmlRootElement(name="kml")
public class Address {

    private String country;

    @XmlPath("Response/Placemark/AddressDetails/Country/CountryName/text()")
    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

}

and

@javax.xml.bind.annotation.XmlSchema( 
    namespace = "http://earth.google.com/kml/2.0",
    /*
    xmlns = { 
          @javax.xml.bind.annotation.XmlNs(prefix = "ns", namespaceURI ="http://earth.google.com/kml/2.0"), 
            },*/
    elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) 
package forum21; 


The following XML will not unmarshal:

<?xml version="1.0" encoding="UTF-8" ?>
<kml xmlns="http://earth.google.com/kml/2.0">
	<Response>
		<name>98 St. Patrick St, Toronto</name>
		<Status>
			<code>200</code>
			<request>geocode</request>
		</Status>
		<Placemark id="p1">
			<address>98 St Patrick St, Toronto, ON, Canada</address>
			<AddressDetails Accuracy="8"
				xmlns="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0">
				<Country>
					<CountryNameCode>CA</CountryNameCode>
					<CountryName>Canada</CountryName>
					<AdministrativeArea>
						<AdministrativeAreaName>ON</AdministrativeAreaName>
						<Locality>
							<LocalityName>Toronto</LocalityName>
							<Thoroughfare>
								<ThoroughfareName>98 St Patrick St</ThoroughfareName>
							</Thoroughfare>
							<PostalCode>
								<PostalCodeNumber>M5T</PostalCodeNumber>
							</PostalCode>
						</Locality>
					</AdministrativeArea>
				</Country>
			</AddressDetails>
			<ExtendedData>
				<LatLonBox north="43.6560378" south="43.6497426" east="-79.3864912"
					west="-79.3927864" />
			</ExtendedData>
			<Point>
				<coordinates>-79.3896388,43.6528902,0</coordinates>
			</Point>
		</Placemark>
	</Response>
</kml>


but this will:

<?xml version="1.0" encoding="UTF-8"?>
<a:kml xmlns:a="http://earth.google.com/kml/2.0">
   <a:Response>
      <a:Placemark>
         <a:AddressDetails>
            <a:Country>
               <a:CountryName>2</a:CountryName>
            </a:Country>
         </a:AddressDetails>
      </a:Placemark>
   </a:Response>
</a:kml>


See:
http://stackoverflow.com/questions/906855/parse-google-geocode-with-xstream
Comment 1 Blaise Doughan CLA 2010-07-21 15:13:15 EDT
Not a bug:  I had the wrong mapping
Comment 2 Eclipse Webmaster CLA 2022-06-09 10:21:05 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink