Question

GML - extract xml:lang

  • 30 September 2016
  • 4 replies
  • 1 view

Badge

Hello,

I'm reading a GML file which contains <roadName> tags as shown below:

<roadName>ROAD NAME IN ENGLISH</roadName>

<roadName xml:lang='xx'>ROAD NAME IN OTHER LANGUAGE</roadName>

The application schema only recognizes RoadName field - output would be a comma separated list of values "ROAD NAME IN ENGLISH, ROAD NAME IN OTHER LANGUAGE". I'm wondering how to extract the language into an attribute as well?

Any help much appreciated. Thanks


4 replies

Userlevel 4
Badge +25

OK, I believe language is an "attribute" of the roadName, rather than a tag value.

If <roadName> was a child of <road> (for example) then the syntax is:

//road/roadName to fetch the road name

//road/roadName/@lang to fetch the language attribute of the road name

You can use that syntax in a number of places. I think you can use it in the XML reader parameters, also in XMLFlattener/Fragmenter transformers, or even an XQueryExtractor.

I think that's all correct, but I will try and create a quick example to make sure.

Userlevel 4
Badge +25

Actually, I'm not sure even that is needed. I just created this XML:

<xml>
<road>
<roadName xml:lang='English'>St George Street</roadName>
</road>
</xml>

And picked the roadName as a source path to read in the XML reader. It returned both roadName and roadName.lang as attributes.

Maybe it's because yours is GML, so you might need to do something with the XML fragments of it.

Badge

Hi @Mark2AtSafe,

could you please send me a quick example using the //road/roadName/@lang expression in XQueryExtractor? I can't see the roadName.lang as an attribute if using the application schema within the GML... However, I can see this attribute if I do ignore the application schema but I don't want to go down this road.

Thanks

Userlevel 2
Badge +17

Hi @honkovam, if you have to use the application schema anyway, a possible way would be: read the road names for each feature with another XML reader, process them as required, and then merge the processed road name attribute to the features which have been read by the GML reader. The concrete way to read, process, and merge depends on the actual schema of the dataset.

Reply