dhis2-users team mailing list archive
-
dhis2-users team
-
Mailing list archive
-
Message #01900
Re: Issue with gml file map data import
Just checked the transform and verified what Lars has said. Currently we
just populate both name and shortname with the name from the gml, which
will cause an error on importing.
Its easy enough to fix the transform. I think (haven't tested this for a
while) that you can even put a patched version of gml2dxf.xsl into a
"transform" directory under your DHIS2_HOME and it will pick that one up in
preference to the builtin one. You will probably have to create the
transform directory. I've attached a version you can try out which
truncates the short names if necessary - place this file under
$DHIS2_HOME/transforms and try again.
Bob
On 4 March 2013 07:34, Lars Helge Øverland <larshelge@xxxxxxxxx> wrote:
> Hi James,
>
> this issue is a bit awkward. Many places we need a short (e.g. 50 char
> long) org unit name to fit in reports, charts. Now on import from external
> sources this might now be available. Previously the org unit shortname
> field was unique so we could not simply cut off the name at the 50th char.
> Now it is no longer unique so that could be an option.
>
> As an immediate workaround you can set the max-length of shortname to 50
> directly in the database. After the import you can deal with this manually
> with SQL, e.g. using the psql substring feature to use only the 50 first
> chars, or whatever you prefer.
>
> http://www.postgresql.org/docs/9.1/static/functions-string.html
>
> regards,
>
> Lars
>
> On Sat, Mar 2, 2013 at 12:21 PM, ChangJames <jamesbjchang@xxxxxxxxxxx>wrote:
>
>> Hi,
>>
>> During my map data import (via gml file), I have encountered an issues.
>>
>> If name length in gml file is longer than 50 character, the import
>> process would throw an error.
>>
>> This is not the intended behavior, right?
>>
>> _______________________________________________
>> Mailing list: https://launchpad.net/~dhis2-users
>> Post to : dhis2-users@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~dhis2-users
>> More help : https://help.launchpad.net/ListHelp
>>
>>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dhis2-users
> Post to : dhis2-users@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~dhis2-users
> More help : https://help.launchpad.net/ListHelp
>
>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:gml="http://www.opengis.net/gml"
>
<xsl:param name="decimalPlaces">4</xsl:param>
<xsl:template match="gml:coordinates">
<coordinatesTuple>
<xsl:value-of select="dhis:gmlToCoords(normalize-space(.),$decimalPlaces)"
disable-output-escaping="yes"
xmlns:dhis="org.hisp.dhis.importexport.xml.Util" />
</coordinatesTuple>
</xsl:template>
<xsl:template match="gml:Polygon">
<feature type="Polygon">
<xsl:apply-templates select=".//gml:coordinates"/>
</feature>
</xsl:template>
<xsl:template match="gml:MultiPolygon">
<feature type="MultiPolygon">
<xsl:apply-templates select=".//gml:coordinates"/>
</feature>
</xsl:template>
<xsl:template match="gml:Point">
<feature type="Point">
<xsl:apply-templates select=".//gml:coordinates"/>
</feature>
</xsl:template>
<xsl:template match="gml:featureMember">
<xsl:variable name="name" select=".//*[local-name()='Name' or local-name()='NAME' or local-name()='name']"/>
<organisationUnit>
<id>0</id>
<uuid/>
<name><xsl:value-of select="$name"/></name>
<shortName><xsl:value-of select="substring($name,1,50)"/></shortName>
<code/>
<openingDate/>
<closedDate/>
<active>true</active>
<comment/>
<geoCode/>
<xsl:apply-templates select="./child::node()/child::node()/gml:Polygon|./child::node()/child::node()/gml:MultiPolygon|./child::node()/child::node()/gml:Point"/>
<lastUpdated/>
</organisationUnit>
</xsl:template>
<xsl:template match="/">
<dxf xmlns="http://dhis2.org/schema/dxf/1.0" minorVersion="1.1">
<organisationUnits>
<xsl:apply-templates select=".//gml:featureMember"/>
</organisationUnits>
</dxf>
</xsl:template>
</xsl:stylesheet>
References