MB: Editing XML

79 views
Skip to first unread message

DenCop (NL)

unread,
Oct 7, 2009, 9:23:20 AM10/7/09
to MapInfo-L
Is it possible to edit XML data from MapBasic?

If got an WFS XML wich i want to edit before opening.


<MI_WFS_TableDefinition xmlns:tiger="http://www.census.gov"
xmlns:nurc="http://www.nurc.nato.int"
..............
<Filters xmlns="http://www.mapinfo.com/tabdef">
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>DBK_ID</ogc:PropertyName>
<ogc:Literal>38</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
</Filters>
</MI_WFS_TableDefinition>

I want to change the filter of DBK_ID to the number (now 38) i need.

someone knows?

DenCop

Bill Thoen

unread,
Oct 7, 2009, 11:51:55 AM10/7/09
to mapi...@googlegroups.com
I don't know about writing XML (you might have to do that yourself), but
check out the XML library that comes with MapBasic. It has support for
the DOM and namespaces, etc. Everything you need to read and parse XML.
Look in the SAMPLES directory for examples.

- Bill Thoen

DenCop (NL)

unread,
Oct 8, 2009, 3:49:02 AM10/8/09
to MapInfo-L
I know there are examples in MapBasic, but i don`t think Parse or Read
can do the trick.

Nobody here has ever worked with xml or WFS from MapBasic?

DenCop

InterRob

unread,
Oct 8, 2009, 9:11:52 AM10/8/09
to mapi...@googlegroups.com
What do you intend to do? Do you wish to edit the server / connection definitions before connecting? Or do you wish to manipulate the server response that would make up the map and the table behind it?

I think you CAN NOT do that last thing. And I think you DO NOT NEED to do the first: just use the Mapbasic "Register Table" expression to connect to whatever WFS-service.


Rob

2009/10/8 DenCop (NL) <den...@gmail.com>

DenCop (NL)

unread,
Oct 8, 2009, 1:37:02 PM10/8/09
to MapInfo-L
Hi InterRob,

I do not want to edit the connection definitions, but the filters. If
you use a WFS server you do not want to download the full table (that
would cost a lot of time). So you make filters. Only the filters are
part of an WFS xml and my filters are not always the same. Thats why i
want to edit the filter and get the information from the server.

Now i want to filter on "DBK_ID" and maybe in the future on areas
(using within?).

I`m i clear in what i want to do?

I already use register table to download the whole table, update and
write back the table.

Do i make an error thinking this way?

DenCop

InterRob

unread,
Oct 8, 2009, 4:10:59 PM10/8/09
to mapi...@googlegroups.com
I was thinking you could provide the filter in the Register Table statement also... But I am not sure; what does your Register Table statement look like?

I can imagine very well that your filters are not always the same!

If I am not mistaking, the filter is stored in the MapInfo TAB also... Probably you can fully generate the appropriate TAB? Just as a different approach :))


Rob

2009/10/8 DenCop (NL) <den...@gmail.com>

InterRob

unread,
Oct 12, 2009, 6:17:08 AM10/12/09
to mapi...@googlegroups.com
Hi DenCop,

Would be nice if we could learn stuff here from eachother... Would be nice if you posted about your approach here; hoping that one day there would be as many answers as there are questions out here...


Rob

2009/10/8 InterRob <rob.m...@gmail.com>

DenCop (NL)

unread,
Oct 13, 2009, 4:58:05 AM10/13/09
to MapInfo-L
hmmm. I posted something here yesterday....

Where did it go?

DenCop

On Oct 12, 12:17 pm, InterRob <rob.mar...@gmail.com> wrote:
> Hi DenCop,
> Would be nice if we could learn stuff here from eachother... Would be nice
> if you posted about your approach here; hoping that one day there would be
> as many answers as there are questions out here...
>
> Rob
>
> 2009/10/8 InterRob <rob.mar...@gmail.com>
>
>
>
> > I was thinking you could provide the filter in the Register Table statement
> > also... But I am not sure; what does your Register Table statement look
> > like?
> > I can imagine very well that your filters are not always the same!
>
> > If I am not mistaking, the filter is stored in the MapInfo TAB also...
> > Probably you can fully generate the appropriate TAB? Just as a different
> > approach :))
>
> > Rob
>
> > 2009/10/8 DenCop (NL) <den...@gmail.com>
>
> >> Hi InterRob,
>
> >> I do not want to edit the connection definitions, but the filters. If
> >> you use a WFS server you do not want to download the full table (that
> >> would cost a lot of time). So you make filters. Only the filters are
> >> part of an WFS xml and my filters are not always the same. Thats why i
> >> want to edit the filter and get the information from the server.
>
> >> Now i want to filter on "DBK_ID" and maybe in the future on areas
> >> (using within?).
>
> >> I`m i clear in what i want to do?
>
> >> I already use register table to download the whole table, update and
> >> write back the table.
>
> >> Do i make an error thinking this way?
>
> >> DenCop- Hide quoted text -
>
> - Show quoted text -

InterRob

unread,
Oct 13, 2009, 8:14:46 AM10/13/09
to mapi...@googlegroups.com
Give it another try... Cannot find it either :s


Rob

2009/10/13 DenCop (NL) <den...@gmail.com>

msydor

unread,
Oct 13, 2009, 11:19:41 AM10/13/09
to MapInfo-L
If you are trying to find your post using the search within the
MapInfo-L it can not be relied upon. The moderators looked into it but
not sure if anything has changed. You might want to try google with
mapinfo-l in the query. Moderators-Any word from on high on search
within the blog?
> > > - Show quoted text -- Hide quoted text -

Bill

unread,
Oct 13, 2009, 4:43:14 PM10/13/09
to MapInfo-L
On Oct 13, 9:19 am, msydor <msy...@parcelinsight.com> wrote:
> If you are trying to find your post using the search within the
> MapInfo-L it can not be relied upon. The moderators looked into it but
> not sure if anything has changed. You might want to try google with
> mapinfo-l in the query. Moderators-Any word from on high on search
> within the blog?

Haven't heard anything, but I didn't know there was a problem. Did you
ask Uffe or Peter about it?

@DenCop: I think your message from yesterday has vanished. The log
shows your last message, but the previous one was 5 days ago. It's
like it never existed. It's possible it got caught up in the daily
spam purge by accident. The moderator's interface for that is pretty
poor; subjects tend to overlap on a small screen and it's easy to
whack the wrong message.
Message has been deleted

DenCop (NL)

unread,
Oct 14, 2009, 12:01:15 PM10/14/09
to MapInfo-L
Thanks for looking into this.

I'll try again. Here we go:

I building an program in mapbasic and got it finished localy (with TAB
files). So the user can update certain layers, add information and add
symbol to build a nice layout window which can be printed.

But now the have seen the program, and the want to use some of the
layers on a portable GIS so the can use it for checks on buildings. I
thought it would be handy to use an WFS server to do this. So i don`t
save the layers localy i save them on an server (much safer and also
for multiuser).

I rebuild my TAB to shape files and put them in a installation from
geoserver at home (very simple installation i must say). And with this
my first problem came. shp support only 10 character column names.....
(no i did not know).
I tried SQL servr 2008 (big installation, and not working)
I tried PostGIS, working but more difficult because i did not know how
to work with it (dont use the the guide on geoserver.org)

Example of Create table for PostGIS
CREATE TABLE "Custom_Polyline"
(gid serial PRIMARY KEY,
"DBK_ID" integer,
"Type" text
);
SELECT AddGeometryColumn
('','Custom_Polyline','the_geom','28992','GEOMETRY',2);

Now this works almost all the time and i can`t use integer with more
then 4 numbers. (something to do with number setting. Over here its
100.000,45) I asked mapinfo to check it out.

Sometimes i get an error from geoserver with "Mark Invalid". But i`ve
i try again and again it works..... (i dont understand it)

Opening in MapInfo
So the server works (almost al the time :-) )
I open the WFS-T layer in mapinfo and use the generated xml in my
mapbasicprogram to open it automatic.

But i need to open the FULL table and then edit this table and save it
back. I want use the row filter to open only one building and not all
of them. This filter is within the XML file and that is because i want
to edit the xml or rebuild it.


example how i register the table
Register Table ApplicationDirectory$()+"XML/WFS_"+sTablename+".xml"
Type "WFS" Charset "WindowsLatin1" CoordSys Earth Projection 20, 109,
"m", 5.387638889, 52.156160556, 0.9999079, 155000, 463000 Bounds
(-99845000, -99537000) (100155000, 100463000) Symbol (35,0,12)
linestyle Pen (1,2,0) regionstyle Pen (1,2,0) Brush
(2,16777215,16777215) Editable Into ApplicationDirectory$()
+"Server_Files/"+"tbl"+sTablename+".TAB"

Open Table ApplicationDirectory$()+"Server_Files/"+"tbl"+sTablename
+".TAB"

DenCop (NL)

unread,
Oct 19, 2009, 4:17:54 AM10/19/09
to MapInfo-L
Uhmmm. Now i told my story and nobody reads it....

I need help with WFS from MapInfo

some more tips / errors:

When reading a table from WFS with an empty char column it makes it
only 1 char. So when editing you can only store 1 char.....
This is to resolve when editing the xml (by hand) and opening the
table again.

MapInfo can`t write an integer back to the server with more then 4
numbers..... So ajust it to a string....(?)

Can MapInfo help?

DenCop

Peter Horsbøll Møller

unread,
Oct 19, 2009, 5:06:25 AM10/19/09
to mapi...@googlegroups.com
DenCop,

When MapInfo Pro downloads the table from the server it looks at the data that is downloaded to determine the width of the char columns. So if there is no data in the column, it will be set to the minimum of 1 characters.

You can try a few things:
1. In the DescribeFeatureType document for you layer you could try to specify a minimum width of the column.
2. In your XML file you could try to set the width of the column
This is the normal look when MapInfo Pro writes the XML file (from a Danish server):
...
<Column xmlns="" nsurl="http://schemas.kms.dk/wfs" ns="au1" name="OBJEKTKODE"

   objrealname="xsd:string" type="Char" width="0"/>
...

It is the 0 for the width parameter that you could try to alter. Or is this what you already did?

Sounds strange if MapInfo Pro can't send a integer with more than four numbers back to the server !?
How is the column specified in the tab file?
Are you sure that it's MapInfo Pro that only sends four numbers back?

Have you tried to use Fiddler to intercept the communications between MapInfo Pro and your server?


Peter Horsbøll Møller
Pitney Bowes Business Insight - MapInfo


2009/10/19 DenCop (NL) <den...@gmail.com>

DenCop (NL)

unread,
Oct 19, 2009, 5:46:10 AM10/19/09
to MapInfo-L
Peter,

Thanks for the quick response. I allready changed the xml from mapinfo
and registrated it again (needs to be done bij MapBasic). Then it
works.

Descripe Feature gives me:

- <xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="0" name="Adres_ID"
nillable="true" type="xsd:int" />
<xsd:element maxOccurs="1" minOccurs="0" name="Straatnaam"
nillable="true" type="xsd:string" />
<xsd:element maxOccurs="1" minOccurs="0" name="Huisnummer"
nillable="true" type="xsd:int" />
<xsd:element maxOccurs="1" minOccurs="0" name="Huisntoevoeging"
nillable="true" type="xsd:string" />
<xsd:element maxOccurs="1" minOccurs="0" name="Postcode"
nillable="true" type="xsd:string" />
<xsd:element maxOccurs="1" minOccurs="0" name="Plaats"
nillable="true" type="xsd:string" />
<xsd:element maxOccurs="1" minOccurs="0" name="Gemeente"
nillable="true" type="xsd:string" />
<xsd:element maxOccurs="1" minOccurs="0" name="the_geom"
nillable="true" type="gml:GeometryPropertyType" />
</xsd:sequence>

I think you mean the Max en Min that i need to change. Through the
webadmin from geoserver i can`t change this. I`ll try it on the server
files... :-)

integer:
On both sides (MapInfo and Geoserver/PostGis) the column is marked as
integer. But i think it has to do with the problem that i live in the
Netherlands and i use a point as a comma and a comma as an point....
(strange people yes....)

If i download the table from the server i still have more than 4
number. But if i change something in that line and update the server.
The number has only four numbers.

If i do this with uDig it does not happen.

I'll try Fiddler to show the logs....

Will be back with more info.

DenCop

On Oct 19, 11:06 am, Peter Horsbøll Møller <mapinf...@horsboll-
moller.dk> wrote:
> DenCop,
>
> When MapInfo Pro downloads the table from the server it looks at the data
> that is downloaded to determine the width of the char columns. So if there
> is no data in the column, it will be set to the minimum of 1 characters.
>
> You can try a few things:
> 1. In the DescribeFeatureType document for you layer you could try to
> specify a minimum width of the column.
> 2. In your XML file you could try to set the width of the column
> This is the normal look when MapInfo Pro writes the XML file (from a Danish
> server):
> ...
> <Column xmlns="" nsurl="http://schemas.kms.dk/wfs" ns="au1"
> name="OBJEKTKODE"
>    objrealname="xsd:string" type="Char" width=*"0"*/>
> ...
>
> It is the 0 for the width parameter that you could try to alter. Or is this
> what you already did?
>
> Sounds strange if MapInfo Pro can't send a integer with more than four
> numbers back to the server !?
> How is the column specified in the tab file?
> Are you sure that it's MapInfo Pro that only sends four numbers back?
>
> Have you tried to use to intercept the communications between
> MapInfo Pro and your server?
>
> Peter Horsbøll Møller
> Pitney Bowes Business Insight - MapInfo
>
> 2009/10/19 DenCop (NL) <den...@gmail.com>
>
>
>
>
>
> > Uhmmm. Now i told my story and nobody reads it....
>
> > I need help with WFS from MapInfo
>
> > some more tips / errors:
>
> > When reading a table from WFS with an empty char column it makes it
> > only 1 char. So when editing you can only store 1 char.....
> > This is to resolve when editing the xml (by hand) and opening the
> > table again.
>
> > MapInfo can`t write an integer back to the server with more then 4
> > numbers..... So ajust it to a string....(?)
>
> > Can MapInfo help?
>

Uffe Kousgaard

unread,
Oct 19, 2009, 5:50:47 AM10/19/09
to mapi...@googlegroups.com
If you use commas in integers, then you sure are strange people :-)

That part aside, all XML needs to be done with . as a decimal comma. No
matter where in the world you are.

Regards
Uffe Kousgaard

DenCop (NL)

unread,
Oct 19, 2009, 5:53:47 AM10/19/09
to MapInfo-L
Ok,

That sounds strange...:S But indeed no comma`s in an Integer in my
"world".

DenCop
> > (strange people yes....)- Hide quoted text -

DenCop (NL)

unread,
Oct 19, 2009, 6:37:20 AM10/19/09
to MapInfo-L
I got Fiddler now, but it don`t see the mapinfo sessions... :-S
> > - Show quoted text -- Hide quoted text -

DenCop (NL)

unread,
Oct 19, 2009, 10:45:37 AM10/19/09
to MapInfo-L
Works now. Had options set to "Use Direct Connection"

DenCop (NL)

unread,
Oct 19, 2009, 10:59:54 AM10/19/09
to MapInfo-L
I`ve i give 10.000 to an column in MapInfo

The update script does this: (Value = 1000)

<wfs:Update xmlns:wfs="http://www.opengis.net/wfs"
typeName="DBK_AVDICT:DBK_Polygon"><wfs:Property><wfs:Name>DBK_ID</
wfs:Name><wfs:Value>1000</wfs:Value></
wfs:Property><wfs:Property><wfs:Name>Section_ID</
wfs:Name><wfs:Value>0</wfs:Value></
wfs:Property><wfs:Property><wfs:Name>Datum</
wfs:Name><wfs:Value>aaaaaaaaaaaaaaaaaaaa</wfs:Value></
wfs:Property><ogc:Filter xmlns:ogc="http://www.opengis.net/
ogc"><ogc:FeatureId fid="DBK_Polygon.91"/></ogc:Filter></wfs:Update></
wfs:Transaction>

If i give 1234567890: (Value 1234)

<wfs:Update xmlns:wfs="http://www.opengis.net/wfs"
typeName="DBK_AVDICT:DBK_Polygon"><wfs:Property><wfs:Name>DBK_ID</
wfs:Name><wfs:Value>1234</wfs:Value></
wfs:Property><wfs:Property><wfs:Name>Section_ID</
wfs:Name><wfs:Value>0</wfs:Value></
wfs:Property><wfs:Property><wfs:Name>Datum</
wfs:Name><wfs:Value>aaaaaaaaaaaaaaaaaaaa</wfs:Value></
wfs:Property><ogc:Filter xmlns:ogc="http://www.opengis.net/
ogc"><ogc:FeatureId fid="DBK_Polygon.91"/></ogc:Filter></wfs:Update></
wfs:Transaction>

If you also what to test it, give me an email... den_cop hotmail
Reply all
Reply to author
Forward
0 new messages