Skip to main content
Question

GML - extract xml:lang

  • September 30, 2016
  • 4 replies
  • 12 views

Forum|alt.badge.img

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

mark2atsafe
Safer
Forum|alt.badge.img+45
  • Safer
  • September 30, 2016

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.


mark2atsafe
Safer
Forum|alt.badge.img+45
  • Safer
  • September 30, 2016

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.


Forum|alt.badge.img
  • Author
  • September 30, 2016

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


takashi
Evangelist
  • October 1, 2016

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings