Skip to main content

Good morning!

I have a process that needs to get the definition for several CRS. To do that, it uses a HTTPRequest:

http://www.opengis.net/def/crs/EPSG/0/4258

http://www.opengis.net/def/crs/EPSG/0/3042

From the response I get, I have to take only the first <gml:name> element:

<gml:name>ETRS89</gml:name>

<gml:name>ETRS89 / UTM zone 30N (N-E)</gml:name>

I wanted to use XQuery, but it requires the declaration of the namespace. The problem is that every CRS definiton has different namespaces:

<gml:GeodeticCRS xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:epsg="urn:x-ogp:spec:schema-xsd:EPSG:1.0:dataset" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:rim="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0" gml:id="ogp-crs-4258" xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:gmd="http://www.isotc211.org/2005/gmd">

<gml:ProjectedCRS xmlns:epsg="urn:x-ogp:spec:schema-xsd:EPSG:1.0:dataset" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:rim="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0" xmlns:xlink="http://www.w3.org/1999/xlink" gml:id="ogp-crs-3042" xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:gmd="http://www.isotc211.org/2005/gmd">

I have also trtied the StringSearcher transformer, but I can't get the proper Regular Expression to extract only what I want.

So I'm a bit lost here. I have the feeling it shouldn't be difficult to get it, but it seems I'm incapable of getting it right.

I'm using FME Desktop 2017.0.

Thanks for any help provided!

This did the trick for me:

matching gml:GeodeticCRS is a bit of a scattershot approach as it expands the entire xml structure but it's often easier to do this than try to pick your way through an XQuery.


This did the trick for me:

matching gml:GeodeticCRS is a bit of a scattershot approach as it expands the entire xml structure but it's often easier to do this than try to pick your way through an XQuery.

That was one of my approaches. The problem is the "Elements to Match" property.

 

 

For some CRS is GeodeticCRS and for others is ProjectedCRS. I have no idea which CRSs will the user pick.
That was one of my approaches. The problem is the "Elements to Match" property.

 

 

For some CRS is GeodeticCRS and for others is ProjectedCRS. I have no idea which CRSs will the user pick.
Right, that complicates matters a bit...

 

But a second XMLFlattener saves the day. One is set to match on gml:ProjectedCRS and the other one on gml:GeodeticCRS. One of them will fail but if you set the Rejected Feature handling in the navigator to continue the translation that's not a problem, it won't terminate.

 

 

I'll be the first to point out that this is an inelegant solution (since today is Talk Like A Pirate Day I'll call it the "grapeshot" approach...), but it does work.
Right, that complicates matters a bit...

 

But a second XMLFlattener saves the day. One is set to match on gml:ProjectedCRS and the other one on gml:GeodeticCRS. One of them will fail but if you set the Rejected Feature handling in the navigator to continue the translation that's not a problem, it won't terminate.

 

 

I'll be the first to point out that this is an inelegant solution (since today is Talk Like A Pirate Day I'll call it the "grapeshot" approach...), but it does work.
Thanks!

 

At least it's good to have something that works!

 

Now I can mess with the XML transformers more relaxed.

 

 


Hi @oscard, the XMLXQueryExtractor with this XQuery expression extracts the first gml:name element under the document root.

declare namespace gml="http://www.opengis.net/gml/3.2";
/*/gml:name>1]

However, the resulting <gml:name> element contains many namespace declarations as its attributes. It's too redundant, so I think it's better to extract the text value of the element with this expression, and then re-concatenate XML tag later, if necessary.

declare namespace gml="http://www.opengis.net/gml/3.2";
/*/gml:namen1]/text()

Hope this helps.


Hi @oscard, the XMLXQueryExtractor with this XQuery expression extracts the first gml:name element under the document root.

declare namespace gml="http://www.opengis.net/gml/3.2";
/*/gml:name>1]

However, the resulting <gml:name> element contains many namespace declarations as its attributes. It's too redundant, so I think it's better to extract the text value of the element with this expression, and then re-concatenate XML tag later, if necessary.

declare namespace gml="http://www.opengis.net/gml/3.2";
/*/gml:namen1]/text()

Hope this helps.

Now I see the light!

 

 

I thought I had to declare all the namespaces of the original document to be able to use XQuery.

 

 

Thanks!

 

 


Reply