Skip to main content
Hi,

 

 

I'm trying to extract a polygon from a xml document, but no luck so far. This is what I got:

 

 

The xml-document looks like this:

 

 

<?xml version="1.0" encoding="UTF-8"?> <ns8:MainNode xmlns:ns8="http://www.somesite.com">   <ns8:Name>test</ns8:Name>   <ns8:No>0065525031</ns8:No>

 

  ......   <ns8:Locatie xmlns:ns3="http://www.opengis.net/gml" axisLabels="x y" srsDimension="2" srsName="epsg:28992" uomLabels="m m">     <ns3:exterior>       <ns3:LinearRing>         <ns3:description xmlns:ns2="http://www.w3c.org/1999/xlink"/>         <ns3:name/>         <ns3:posList>96154 411149 96072 411090 96153 410990 96235 411069 96154 411149</ns3:posList>       </ns3:LinearRing>     </ns3:exterior>   </ns8:Locatie>

 

  .... </ns8:MainNode >

 

I'm reading this xml-file with an FME xml reader, with the following setting:

 

 Configuration Type: Feature Paths

 

 Elements to match: MainNode

 

 Flattening Enabled

 

 

Now my reader outputs as a whole bunch of attributes:

 

  Name

 

  No

 

  ..

 

  Locatie.axisLabels

 

  Locatie.exterior.LinearRing.description

 

  Locatie.exterior.LinearRing.description.ns

 

  Locatie.exterior.LinearRing.name

 

  Locatie.exterior.LinearRing.postList

 

  Locatie.ns3

 

  Locatie.srsDimension

 

  Locatie.srsName

 

  Locatie.uomLabels

 

  ..

 

 

I though I should use the GeometryhReplacer to extract the geometry from this, but I'm unsure how to configure it:

 

-What is the Geometry encoding I should use?

 

-What is the correct Source Geometry Atrribute

 

 

I hope someone can help.

 

 

Regards,

 

Koen Vermeer
My goal is to write everything in an Sql Server Database table.

 

 

I don't just need geometry, I also need all the attributes such as 'Name', 'No' (and 20 other I've hidden in my above message behind the dots)

 

 

That's why I used a xml reader, how do I get all the other attributes from the text reader output.

 

 

Isn't this possible with the xml reader?
'So use the xml reader and the replacer set to the xml_fragment.
Hi Itay,   (tnx for your quick replies by the way)

 

 

I tried that.

 

 

-Xml reader

 

-replacer Geomery encoding: GML

 

-replacer Source Geometry Attribute: xml_fragment 

 

 

Execution failes on the replacer:

 

The @GMLGeometry function failed to parse the GML text from the specified 'xml_fragment' attribute, check the attribute for valid XML data.
Strange, because it works with the xml example you provided,

 

Can you pass the xml via a xml validator with succes?
Strange, don't know where that last fault came from, but when I deleted and added the xml reader again it worked.

 

 

Thanks!!

 

 

BUT:

 

It appears that my xml has more than one node with gml data (sorry for not including that the first time)

 

  <ns8:Pngformaat>     <ns8:OmsluitendeRechthoek>       <ns3:Envelope xmlns:ns3="http://www.opengis.net/gml" axisLabels="x y z" srsDimension="2" srsName="epsg:28992" uomLabels="m m m">         <ns3:lowerCorner>96072 410990</ns3:lowerCorner>         <ns3:upperCorner>96235 411149</ns3:upperCorner>       </ns3:Envelope>     </ns8:OmsluitendeRechthoek>     <ns8:PixelsBreed>2282</ns8:PixelsBreed>     <ns8:PixelsHoog>2226</ns8:PixelsHoog>   </ns8:Pngformaat>

 

 

So now the coordinates from Locatie and Pngformaat nodes are combined in one geometry.

 

 

Any idea how I can separate this?
If the geometries are combined (aggregates) the deaggragator will split in into individual features.
The geometries are combined as a multiple geometry:

 

 

This is what the Logger outputs for this:

 

 

Coordinate System: `EPSG:28992'

Geometry Type: Multiple Geometry

Front Appearance Reference: `<inherited_or_default_appearance>'

Back Appearance Reference: `<inherited_or_default_appearance>'

Number of Geometries: 2

--------------------------------------

Geometry Number: 0

Geometry Type: IFMEPolygon

Boundary:

Geometry Type: IFMELine

Number of Coordinates: 5 -- Coordinate Dimension: 2

(96154,411149)(96072,411090)(96153,410990)(96235,411069)(96154,411149)

--------------------------------------

Geometry Number: 1

Geometry Type: IFMEPolygon

Name(utf-16): `OmsluitendeRechthoek'

Boundary:

Geometry Type: IFMELine

Number of Coordinates: 5 -- Coordinate Dimension: 2

(96072,410990)(96072,411149)(96235,411149)(96235,410990)(96072,410990)

==========================================================

 

 

Each geometry should be saved in a separate field in SQL Server.

 

I'm not sure how I should do this.

 

 

Should I set a name on each Geometry? How do I do that?

 

 
Hoi Koen,

 

 

Did you try the deaggregator? that should separate the features.

 

See https://www.dropbox.com/sh/vn337z1vwis00bw/ByQ_C5XK_Z

 

Otherwise consider other elements to mach than only the main node.

 

Itay
Yes, but the deaggregator splits everything into two features, and it should be saved in sql server as 1 feature with 2 geometry fields.
So basically you just need to write the aggregates (?) since SQL Server supports that type of geometry.

So I don't need the deaggregator?

 

 

But how do I define which geometry will be saved in which field?

 

Should I directly connect the GeometryReplacer wtih the SQL Server Spatial Writer?

I'm really lost here...


Hi Koen,

 

 

if the aggregate contains geometries with names that match the spatial columns of the table being written, the geometries will be written to the appropriate columns.

 

 

Its always advisable to check the documentation.

 

 

Hope this helps
Forgot to mention that I personally dont have experience with SQL Server and I hope that another group member with experience can pitch in....

 

 

So no you dont need the deaggregator , you need to define the geometries names to match the geometry column's names in your destination table.
Yes, if finally worked.

 

 

Already had that this morning, but then I wasn't able to change the names on the geometries, and then I was distracted by experimenting with that deaggregator.

 

 

No I got the geometry names set with two serial GeometryPropertySetters which check on the current geometry name and everything works.

 

 

 

Thanks for your help, and your patience with me.

 

Great to know this site where questions are answered within minutes with useful comments!!

Reply