I have a list of Australian Toilets that i want to map on GE using xQuery to transform into a KML document. The data set im using has a default namespace of xmlns="http://toiletmap.gov.au/".
When I do the xQuery transfer Im able to extract the coordinates/name/description as needed. But the document is not a valid KML document because i havent used the kml default namespace of xmlns="http://earth.google.com/kml/2.1".
How am i supposed to incorporate both namespaces? If i leave out the name space then the xQuery transformation is blank and unable to extract the needed data.
I thought about adding a prefix like xmlns:au="http://toiletmap.gov.au/". But that didnt help, even when i named the {data($x/Name)} element as such.
Please let me know what im doing wrong, i feel i havent fully grasped the idea of how namespaces work.
This is the xQuery:
<kml xmlns="http://toiletmap.gov.au/">
<Document>
<Folder>
{
let $doc := doc("ToiletmapExport_180801_090000.xml")
for $x in $doc/ToiletMapExport/ToiletDetails
where $x/@Latitude <= (-34.74526121+0.25)
and $x/@Latitude >= (-34.74526121-0.25)
and $x/@Longitude >= (146.5505775-0.25)
and $x/@Longitude <= (146.5505775+0.25)
return if (($x/AccessibilityDetails/AccessibleMale='true'
and $x/AccessibilityDetails/AccessibleFemale='true')
or $x/AccessibilityDetails/AccessibleUnisex='true')
then
<Placemark>
<name >{data($x/Name)}</name>
<description>FacilityType: {data($x/GeneralDetails/FacilityType)}<br></br>
Town: {data($x/Town)}<br></br>
Male: {data($x/AccessibilityDetails/AccessibleMale)} Female: {data($x/AccessibilityDetails/AccessibleFemale)}<br></br>
Unisex: {data($x/AccessibilityDetails/AccessibleUnisex)}
</description>
<Point>
<coordinates>{data($x/@Longitude)},{data($x/@Latitude)}</coordinates>
</Point>
</Placemark>
else ()
}
</Folder>
</Document>
You haven't really shown an input sample but when working with XPath and XQuery any path expressions to select nodes in namespaces don't have to use the same prefix or the default namespace (i.e. no prefix) to select nodes from a certain namespace, what matters is to declare a certain prefix for the right namespace with e.g. declare namespace toi = "http://toiletmap.gov.au/";
and then to use that prefix with e.g. $doc/au:ToiletMapExport/au:ToiletDetails
in all your path expressions where you want to select input from that namespace. For the output you can then set the KML namespace.