[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cgiapp] [OT] Which Parser is "best"


Markus,

Your parsing problem looks like it might be solved using XML and XSLT.
If your data were in XML (and it looks like they could easily be put
into that form), you could access the metadata using any number of XML
tools (look at XPath and XML::Twig). Using either native Perl data
structures or XSLT, you would be able to output those data through
HTML::Template or as XSLT-converted HTML through C::A without H::T.

For example, to convert to XML would require only a replacement of the
END tags with a closing XML tags (like <LAYER></LAYER>. XSLT would make
this task easy. As an example (still rough and unvalidated, made over my
morning coffee...):

<LAYER NAME="bg121>
<METADATA>
	<LTITLE>Gr&uuml;nfl&auml;chen</LTITLE>
  <DATA>/data/muc/shapes_ms/gruen</DATA>
  <CLASSITEM>code</CLASSITEM>
  <CLASS NAME="">
    <SYMBOL>0</SYMBOL>
    <COLOR R="166" G="255" B="165"\>
    <OUTLINECOLOR R="195" G="255" B="195"\>
  </CLASS>
  <TYPE>polygon</TYPE>
</LAYER>

Take a look at the O'Reilly guide "Perl & XML." 

- John



On Fri, 2003-05-23 at 04:00, suppressed wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hi list,
> 
> as there seem to be very experienced and helpful perl programmers on
> this list, I dare to ask a off-topic question:
> 
> I want to set up a C::A for manipulating mapfiles for the UMN
> mapserver (http://mapserver.gis.umn.edu) with html forms. The mapfiles
> are in the following form (just a cutout):
> 
> LAYER NAME bgl21
>   METADATA
>     LTITLE "Grünflächen"
>   END
>   DATA "/data/muc/shapes_ms/gruen"
>   CLASSITEM "code"
>   CLASS NAME ""
>     SYMBOL 0
>     COLOR 166 255 165
>     OUTLINECOLOR 195 255 195
>   END # class
>   TYPE polygon
> END # layer bgl21
> 
> The newlines are not obligatory, it could be a long string; comments
> are denoted by #. Objects like LAYER or CLASS are always ended by END.
> The files are case insensitive.
> 
> My only approach with parsing files like this is with regexps, but
> maybe this is not the best way as those mapfiles can be several hundred
> lines long.
> 
> Therefore I am looking for helpful advice.
> 
> 
> Markus
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.0.6 (GNU/Linux)
> Comment: Processed by Mailcrypt 3.5.6 and Gnu Privacy Guard <http://www.gnupg.org/>
> 
> iD8DBQE+zdUxxxUzQSse11ARAoiFAJ0VaHrjzxiJPGPI91uVe9QYa8iVMgCdF4XO
> PkFRVzH06T1hp3fZr3rncy0=
> =ZaEp
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> Web Archive:  http://www.mail-archive.com/suppressed/
> To unsubscribe, e-mail: suppressed
> For additional commands, e-mail: suppressed
-- 
John Crowley <suppressed>
johncrowley.net


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.