List Info

Thread: Re: how to do custom formula functions embedded in the document?




Re: how to do custom formula functions embedded in the document?
user name
2007-08-01 03:09:13
eh... that's a start. how about xml processing ? i need a
dom-like access
and very posibly features like xpath and xsl
transformation.

On 8/1/07, Andrew Douglas Pitonyak <andrewpitonyak.org> wrote:
>
> Ionel Maries Cristian wrote:
> > I belive some form of macro would be suitable for
this job.
> > The function has to fetch some xml from a remote
url, the
> > xml has to be parsed and the parameters for the
url are
> > sent as post data (as xml)
> > I've failed to find apis for doing url fetching in
basic.
> > Python would be suitable for doing that (rich
standard
> > library, good docs) but, again, i've failed to
find a way to use
> > python functions as formula functions (basic
functions
> > are callable from a formula but, there is no
obvious way
> > to call some python functions from the basic
macro)
> >
> > Any help is apreciated.
> >
> Have you looked at any "stock quote" examples
with Calc? They usually
> obtain a document from a URL of some sort and then
parse it.
>
> --
> Andrew Pitonyak
> My Macro Document: http://www.pi
tonyak.org/AndrewMacro.odt
> My Book: http://w
ww.hentzenwerke.com/catalog/oome.htm
> Info:  http://www.pitonyak.or
g/oo.php
> See Also: http://documentation.openoffice.org/HOW_TO/index.html
>
>
------------------------------------------------------------
---------
> To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
> For additional commands, e-mail: dev-helpapi.openoffice.org
>
>


-- 
http://ionel.zapto.org
ionel.
Re: how to do custom formula functions embedded in the document?
user name
2007-08-01 05:04:26
Hi Christian,

Alle 10:09, mercoledì 1 agosto 2007, Ionel Maries Cristian
ha scritto:
> eh... that's a start. how about xml processing ? i need
a dom-like access
> and very posibly features like xpath and xsl
transformation.

I think that you could try with the
com.sun.star.xml.dom.DocumentBuilder 
service, but I've no experience with it.
This is a quick experimenti that I've just tried:

--------------------8<--------------------
REM  *****  BASIC  *****

Sub ExampleDOM
oDocBuilder =
createUnoservice("com.sun.star.xml.dom.DocumentBuilder&
quot;)
oUcb =
createUnoService("com.sun.star.ucb.SimpleFileAccess&quo
t;)
sUrl = "file:///home/paolo/CodeSnippet.snip"
oFile = oUcb.OpenFileReadWrite(sUrl)

oXmlDoc = oDocBuilder.parse(oFile.GetInputStream)
'use xray to inspect oXmlDoc and discover how to
'work with child-nodes and xml-attributes
End Sub
--------------------8<--------------------


In alternative you can use a SAX parser:
check the source of the SnippetCreator utility:
http://www.paolo-mantovani.org/downloads/SnippetCreator/

You'll find a starbasic module "ImportXML" that
uses the 
com.sun.star.xml.sax.Parser service.


ciao
Paolo M

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )