[xsd-users] Resolving xlinks in a GML file
Laurence Davies
laurence.davies at unsw.edu.au
Sun Jun 28 21:51:29 EDT 2015
Hi Boris,
Thanks for your reply.
You've noted the xlink that points to raw data, so perhaps I provided a bad example.
In GML there is the concept of the property type (if you're interested, it is discussed here: https://www.seegrid.csiro.au/wiki/AppSchemas/GmlImplementation#Implementation_of_properties ) which is my main concern at present. The below XML should illustrate the URLs that I need to resolve and parse if the resolution succeeds:
<geo:PositionTimeSeries gml:id="ID_PTS_1" srsName="http://www.opengis.net/gml/srs/epsg.xml#4938">
<geo:atNode xlink:href="http://wfs.geodesyml.org/nodes?identifer" />
...
</geo:PositionTimeSeries>
HTTP result from the hypothetical web service http://wfs.geodesyml.org/nodes?hashidentifer would look like:
<wfs:FeatureCollection numberMatched="1" numberReturned="1" timeStamp="2015-06-29T00:06:01.221Z" xsi:schemaLocation="urn:xml-gov-au:icsm:egeodesy:0.2 http://icsm.govspace.gov.au/files/2015/05/GeodesyML.xsd http://www.opengis.net/gml/3.2 http://schemas.opengis.net/gml/3.2.1/gml.xsd http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd">
<wfs:member>
<geo:Node gml:id="node_11328">
<gml:name codeSpace="urn:vic-gov-au:icsm:egeodesy:geodesyml_node-name">node_11328</gml:name>
...
</geo:Node>
</wfs:member>
</wfs:FeatureCollection>
Would the added layer of parsing a WFS response pose a problem? If the URL just returns a <geo:Node>...</geo:Node> perhaps I could use the following template:
/* second argument takes the form:
* std::[auto|unique]_ptr<type> name (const std::basic_string<C>& uri, xml_schema::flags = 0, const xml_schema::properties& = xml_schema::properties ());
*/
template<class P, class T>
std::auto_ptr<T> PropertyResolver(P &p,
std::auto_ptr<T> (*create_global_element) (const ::std::string& uri, xml_schema::flags, const xml_schema::properties&)
)
{
typedef ::xlink::hrefType href_type;
typedef ::xsd::cxx::tree::optional< href_type > href_optional;
href_optional ho = p.href();
if (ho.present()) {
href_type h = ho.get();
if (h.at(0) == '#')
{
xml_schema::idref ref(h.substr(1), 0, &p);
return ref.get();
}
else
{
/* Resolve the URI externally */
xercesc::XMLUri xuri(xercesc::XMLString::transcode(h));
if (xuri.isValidURI())
{
/* @todo Is this an XPointer? Split at the # and resolve the base,
* then the XPointer expression */
/* Try parsing using the xsd type */
return create_global_element(h,0,xml_schema::properties ());
}
else
{
throw runtime_error("URI for xlink:href is not valid.");
}
}
}
return std::auto_ptr<T>(null);
}
This leads to another issue that I'm having: The generation of parsers for global elements. I have global elements that substitute for a global abstract element, and the parsers (documented here: http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#3) don't seem to be generated for these elements. Am I missing a crucial option to enable the generation of these parsers? For example, consider the following extract from my schema:
<element name="AbstractPosition" substitutionGroup="gml:AbstractFeature"/>
<element name="Position" type="geo:PositionType" substitutionGroup="geo:AbstractPosition"/>
<complexType name="PositionType">
<complexContent>
<extension base="gml:AbstractFeatureType">
....
</extension>
</complexContent>
</complexType>
Thank you again and kind regards,
Laurence Davies
____________________
Research Assistant in eGeodesy
CRC-SI, UNSW
Desk phone: (03) 8636 2373
Mobile: 0427 519 289
________________________________________
From: Boris Kolpackov [boris at codesynthesis.com]
Sent: Saturday, 27 June 2015 3:46 AM
To: Laurence Davies
Cc: xsd-users at codesynthesis.com
Subject: Re: [xsd-users] Resolving xlinks in a GML file
Hi Laurence,
Laurence Davies <laurence.davies at unsw.edu.au> writes:
> I found a relevant solution you provided in 2008 on this subject in
> the email below that covers the gml:id case but not the latter. Would
> you know what call I would need to make to resolve a URL and, if
> possible, a URN?
If href is to a gml:id, it means it is to a node in the same object
model (or to some element in the same document, in XML terms). If
href is a URL/URN like below, what does it point to?
xlink:href="ftp://ftp.ga.gov.au/geodesy-outgoing/gnss/solutions/apref/apr18287.snx"
When you say "what call I would need to make to resolve a URL" what
do you want it to be resolved to? A byte stream? A file (that got
downloaded) on disk? Maybe, if it is always an image, you want this
call to display the image on the user's computer?
Boris
More information about the xsd-users
mailing list