LuaSoap and argument containting an '&'

classic Classic list List threaded Threaded
20 messages Options
Reply | Threaded
Open this post in threaded view
|

LuaSoap and argument containting an '&'

Laurent FAILLIE
Hello,

How to encode an argument that contains an ampersand ?

My code is the following :

 client.call {
        url = rendez_vous,
        soapaction = "nanaafoutre",
        method = "Report",
        entries = {
            {
                    tag="status",
                    attr = { "xsi:type", ["xsi:type"] = "xsd:boolean", },
                    rc == 0 and "true" or "false"
                },{
                    tag="output",
                    attr = { "xsi:type", ["xsi:type"] = "xsd:string", },
                    res
                }
            }
    }
 
but evrytime the string res contains "&" character, I got following error :

lua: /usr/local/share/lua/5.1/soap/client.lua:78: Error on request: 1

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Client</faultcode><faultstring>Bad Request</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>

So what have I to do ?

Thanks

Laurent
Reply | Threaded
Open this post in threaded view
|

Re: LuaSoap and argument containting an '&'

Sean Conner
It was thus said that the Great Laurent FAILLIE once stated:

> Hello,
>
> How to encode an argument that contains an ampersand ?
>
> My code is the following :
>
>  client.call {
>         url = rendez_vous,
>         soapaction = "nanaafoutre",
>         method = "Report",
>         entries = {
>             {
>                     tag="status",
>                     attr = { "xsi:type", ["xsi:type"] = "xsd:boolean", },
>                     rc == 0 and "true" or "false"
>                 },{
>                     tag="output",
>                     attr = { "xsi:type", ["xsi:type"] = "xsd:string", },
>                     res
>                 }
>             }
>     }
>  
> but evrytime the string res contains "&" character, I got following error :
>
> lua: /usr/local/share/lua/5.1/soap/client.lua:78: Error on request: 1
>
> <?xml version="1.0" encoding="UTF-8"?>
> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Client</faultcode><faultstring>Bad Request</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
>
> So what have I to do ?

  This is less a Lua issue and more of an XML issue, but the answer is:  any
time you want to encode "&" in an XML document (and SOAP is encoded in XML)
you need to convert it to "&amp;".  

  An easy way to do that is

        res = res:gsub("%&","&amp;")

  A better way is to see of the library you are using can encode strings for
XML and use that.

  -spc (As there are some other characters you may need to watch out for)




Reply | Threaded
Open this post in threaded view
|

Re: LuaSoap and argument containting an '&'

Daurnimator
On 19 January 2012 10:01, Sean Conner <[hidden email]> wrote:
 An easy way to do that is

       res = res:gsub("%&","&amp;")


& doesn't need to be escaped in lua patterns; and in fact: shouldn't.

res = res:gsub("&","&amp;")

will do

As a note; other special entities need to be escaped too:

res = res:gsub("[<>&\"]",{ ["<"] = "&lt;" , [">"]="&gt;" , ["&"]="&amp;" , ["\""] = "&quot;" } )

D
Reply | Threaded
Open this post in threaded view
|

Re: LuaSoap and argument containting an '&'

Tomás Guisasola-2
  Hi

On Thu, 19 Jan 2012, Daurnimator wrote:
...
> As a note; other special entities need to be escaped too:
>
> res = res:gsub("[<>&\"]",{ ["<"] = "&lt;" , [">"]="&gt;" , ["&"]="&amp;" ,
> ["\""] = "&quot;" } )
  Next version of LuaSOAP will automatically encode these characters
and also "'" which will be converted to "&apos;".

  Regards,
  Tomás
Reply | Threaded
Open this post in threaded view
|

Re: LuaSoap and argument containting an '&'

Laurent FAILLIE

Hi

On Thu, 19 Jan 2012, Daurnimator wrote:
...
> As a note; other special entities need to be escaped too:
>
> res = res:gsub("[<>&\"]",{ ["<"] = "&lt;" , [">"]="&gt;" , ["&"]="&amp;" ,
> ["\""] = "&quot;" } )

I already replied to Sean but unfortunately forgeting the list :(
It's already what I'm doing but the result is the same as corresponding entities start themselve by a '&'.

Tomas wrote :
>    Next version of LuaSOAP will automatically encode these characters
> and also "'" which will be converted to "&apos;".

Cool : when is the release forcasted ?

Thanks,

Laurent

Reply | Threaded
Open this post in threaded view
|

Re: LuaSoap and argument containting an '&'

Tomás Guisasola-2
  Hi Laurent

> Cool : when is the release forcasted ?
  I am trying to make LuaSOAP 3.0 work with all Lua 5.X versions,
which I think isn't difficult, just boring :-(
  I am also modifying some details and improving the docs.
I am considering dropping soap.client.https, since it is the same as
LuaSec's ssl.https.  This will add an incompatibility. Previous code
like the following:

local client = require"soap.client"
require"soap.client.https"

  Would have to be rewritten as:

local client = require"soap.client"
client.https = require"ssl.https"

  What do you think about?
  Tomás
Reply | Threaded
Open this post in threaded view
|

Re: LuaSoap and argument containting an '&'

Laurent FAILLIE
Hi Tomas,

> > Cool : when is the release forcasted ?
>    I am trying to make LuaSOAP 3.0 work with all Lua 5.X versions,
> which I think isn't difficult, just boring :-(

I've tried to upgrade to 3.0 but LuaRocks stick in 2.0.2.1. : I'm currently doing some tests regarding '&' using a webMethods server and my Lua customer, but I'm facing some problems supposed to be solved by 3.0 (soap headers before body).
Will try to upgrade directly from source tomorrow ...
I'm still running Lua 5.1 as 5.2 isn't ported yet to Gentoo.

>    I am also modifying some details and improving the docs.

speaking about documentation improvement, "download" page's LuaForge link is pointing to cgilua instead of luasoap :)

> I am considering dropping soap.client.https, since it is the same as
> LuaSec's ssl.https.
> [...]
>What do you think about?

I'm using only straight http, but I always think it's better to avoid rundondancies :)

Bye

Laurent
Reply | Threaded
Open this post in threaded view
|

Re: LuaSoap and argument containting an '&'

Laurent FAILLIE
Hi,

I'm still trying to investigate the issue but using a SAG's webMethods provider this time (to be sure the problem doesn't come from PHP soap layer).

1/ Unfortunately, it doesn't work at all as webMethods' is providing an soap:Header before the body.

2/ As it seems this issue is solved with LuaSoap 3.0, I tried to update LuaSoap but I got some compatibility error with Lua 5.1.4 (sorry, I don't have noted the error I got).

3/ then I've tried to install Lua 5.2 from source + LuaSoap 3.0 + LuaSocket 2.0.2 still from source.
And this time, I've got following messages :

/home/laurent/Softs/bin/lua: error loading module 'socket.core' from file '/home/laurent/Softs/lib/lua/5.2/socket/core.so':
    /home/laurent/Softs/lib/lua/5.2/socket/core.so: undefined symbol: luaL_typerror
stack traceback:
    [C]: in ?
    [C]: in function 'require'
    /home/laurent/Softs/share/lua/5.2/socket.lua:13: in main chunk
    [C]: in function 'require'
    /home/laurent/Softs/share/lua/5.2/socket/http.lua:11: in main chunk
    [C]: in function 'require'
    /home/laurent/Softs/share/lua/5.2/soap/client.lua:13: in main chunk
    [C]: in function 'require'
    TstEcho:1: in main chunk
    [C]: in ?

So, all, in all, I'm not able to run LuaSoap on 5.2 and I can't test with webMethods at all.
I'm continuing to trace down this nasty error using old LuaSoap 2.0.2 ...

Bye

Laurent
Reply | Threaded
Open this post in threaded view
|

Re: LuaSoap and argument containting an '&'

Laurent FAILLIE
Hello,

> I'm continuing to trace down this nasty error using old LuaSoap 2.0.2 ...

So I found where my problem was : in fact string argument have to be URL encoded (as LuaSoap doesn't do it by itself).
But, the result MUST NOT contain any HTML or XML tag, otherwise it is considered as invalid XML segment.

It's solving my issue but it's a bit annoying as I can't provide pre-formated response (I mean, rich HTML response).

I don't know (yet ?) how to bypass ... providing this kind of response is totally transparent for the PHP soap layer and my goal is to get the same functionnalities b/w my PHP or LUA clients ...

Bye

Laurent
Reply | Threaded
Open this post in threaded view
|

Re: LuaSoap and argument containting an '&'

Laurent FAILLIE


Hello,

So, I found the better solution with is to embed the response inside CDATA tags which avoid any change in the response message.

I suggest to patch luasoap to make developer life easier :)

Bye

Laurent


Reply | Threaded
Open this post in threaded view
|

Re: LuaSoap and argument containting an '&'

Jay Carlson
(This isn't aimed at Laurent--I am just confused.)

On Feb 21, 2012 5:44 PM, "Laurent FAILLIE" <[hidden email]> wrote:

> So, I found the better solution with is to embed the response inside CDATA tags which avoid any change in the response message.

Unless the string contains "]]>" of course.

There is no way to avoid escaping arbitrary strings included in XML documents.

> I suggest to patch luasoap to make developer life easier :)

Through the life of this thread I've completely lost track of what
LuaSoap actually does for me. As of 3.0 it appears it will correctly
marshal LOM into XML; what else is needed?

CDATA is just another escape mechanism. The choice between it and
&lt/&amp escaping is a matter of coding efficiency. CDATA has higher
overhead but after the third escaped entity it's more
efficient--unless your text has many more "]]>" sequences than "<" and
"&". This is the kind of thing a good XML library should handle for
me: getting this right once, so I just don't naively strsub every time
I need output. A heuristic of "use CDATA if the string starts with '<'
and is longer than ten characters" is a good start, as is a population
count of [&<] of the first hundred characters.

There are a couple other things I want in an XML output library,
starting with...UTF-8 validity, and barring invalid codepoints.

Jay

Reply | Threaded
Open this post in threaded view
|

LuaSoap 3.0 vs Lua 5.1

Laurent FAILLIE
In reply to this post by Laurent FAILLIE
Hi Tomas,

Do you have any idea when you will be able to release LuaSoap 3.0 and if it will be compatible with Lua 5.1 ?

It did another try (as I still have my requirement to consume some webMethod's webservices) but I'm still not able to install all dependancies : i.e. luasocket is 5.1 only, ...

Thanks

Laurent


From: Laurent FAILLIE <[hidden email]>
To: Laurent FAILLIE <[hidden email]>; Tomas Guisasola Gorham <[hidden email]>; Lua mailing list <[hidden email]>; Lua mailing list <[hidden email]>
Sent: Wednesday, February 8, 2012 11:29 PM
Subject: Re: LuaSoap and argument containting an '&'

Hi,

I'm still trying to investigate the issue but using a SAG's webMethods provider this time (to be sure the problem doesn't come from PHP soap layer).

1/ Unfortunately, it doesn't work at all as webMethods' is providing an soap:Header before the body.

2/ As it seems this issue is solved with LuaSoap 3.0, I tried to update LuaSoap but I got some compatibility error with Lua 5.1.4 (sorry, I don't have noted the error I got).

3/ then I've tried to install Lua 5.2 from source + LuaSoap 3.0 + LuaSocket 2.0.2 still from source.
And this time, I've got following messages :

/home/laurent/Softs/bin/lua: error loading module 'socket.core' from file '/home/laurent/Softs/lib/lua/5.2/socket/core.so':
    /home/laurent/Softs/lib/lua/5.2/socket/core.so: undefined symbol: luaL_typerror
stack traceback:
    [C]: in ?
    [C]: in function 'require'
    /home/laurent/Softs/share/lua/5.2/socket.lua:13: in main chunk
    [C]: in function 'require'
    /home/laurent/Softs/share/lua/5.2/socket/http.lua:11: in main chunk
    [C]: in function 'require'
    /home/laurent/Softs/share/lua/5.2/soap/client.lua:13: in main chunk
    [C]: in function 'require'
    TstEcho:1: in main chunk
    [C]: in ?

So, all, in all, I'm not able to run LuaSoap on 5.2 and I can't test with webMethods at all.
I'm continuing to trace down this nasty error using old LuaSoap 2.0.2 ...

Bye

Laurent


Reply | Threaded
Open this post in threaded view
|

Re: LuaSoap 3.0 vs Lua 5.1

Laurent FAILLIE
Well, it's in fact luarocks that is not up to date and I was able to upgrade to 3.0 using the stock tarball.

But luasoap still fail to decode :

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Header xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"></SOAP-ENV:Header><SOAP-ENV:Body>
<ser-root:CheckEntryPointsResponse xmlns:ser-root="http://eux932.sgp.st.com/STAdminMisc/StopB2BProcessing/CheckEntryPointsWS"><ErrorMessages>
<ArrayOfstringItem>Port FilePollingListener:/home/wmadm/usr/laurent/tst is disabled</ArrayOfstringItem>
<ArrayOfstringItem>Task STAdmin.purge:purgeISData is suspended</ArrayOfstringItem>
<ArrayOfstringItem>SAPListener STSAPResource.B2BCRM.listener:B2BCRM is NOT enabled</ArrayOfstringItem></ErrorMessages></ser-root:CheckEntryPointsResponse></SOAP-ENV:Body>
</SOAP-ENV:Envelope>

The error came from the assert of /usr/local/share/lua/5.1/soap/client.lua Line 96.

I'm still investigating ...


From: Laurent FAILLIE <[hidden email]>
To: Tomas Guisasola Gorham <[hidden email]>; Lua mailing list <[hidden email]>
Sent: Tuesday, July 10, 2012 5:04 PM
Subject: LuaSoap 3.0 vs Lua 5.1

Hi Tomas,

Do you have any idea when you will be able to release LuaSoap 3.0 and if it will be compatible with Lua 5.1 ?

It did another try (as I still have my requirement to consume some webMethod's webservices) but I'm still not able to install all dependancies : i.e. luasocket is 5.1 only, ...

Thanks

Laurent


From: Laurent FAILLIE <[hidden email]>
To: Laurent FAILLIE <[hidden email]>; Tomas Guisasola Gorham <[hidden email]>; Lua mailing list <[hidden email]>; Lua mailing list <[hidden email]>
Sent: Wednesday, February 8, 2012 11:29 PM
Subject: Re: LuaSoap and argument containting an '&'

Hi,

I'm still trying to investigate the issue but using a SAG's webMethods provider this time (to be sure the problem doesn't come from PHP soap layer).

1/ Unfortunately, it doesn't work at all as webMethods' is providing an soap:Header before the body.

2/ As it seems this issue is solved with LuaSoap 3.0, I tried to update LuaSoap but I got some compatibility error with Lua 5.1.4 (sorry, I don't have noted the error I got).

3/ then I've tried to install Lua 5.2 from source + LuaSoap 3.0 + LuaSocket 2.0.2 still from source.
And this time, I've got following messages :

/home/laurent/Softs/bin/lua: error loading module 'socket.core' from file '/home/laurent/Softs/lib/lua/5.2/socket/core.so':
    /home/laurent/Softs/lib/lua/5.2/socket/core.so: undefined symbol: luaL_typerror
stack traceback:
    [C]: in ?
    [C]: in function 'require'
    /home/laurent/Softs/share/lua/5.2/socket.lua:13: in main chunk
    [C]: in function 'require'
    /home/laurent/Softs/share/lua/5.2/socket/http.lua:11: in main chunk
    [C]: in function 'require'
    /home/laurent/Softs/share/lua/5.2/soap/client.lua:13: in main chunk
    [C]: in function 'require'
    TstEcho:1: in main chunk
    [C]: in ?

So, all, in all, I'm not able to run LuaSoap on 5.2 and I can't test with webMethods at all.
I'm continuing to trace down this nasty error using old LuaSoap 2.0.2 ...

Bye

Laurent




Reply | Threaded
Open this post in threaded view
|

Re: LuaSoap 3.0 vs Lua 5.1

Laurent FAILLIE
Well, for the initial error, I found it : it was a sequel of the previous install.

Now, 3.0 install is not 5.1 compliant : to make it working, you have to

cd /usr/local/share/lua/5.1/
ln soap.lua init.lua

And now it is failling a
/usr/local/share/lua/5.1/soap/init.lua:215: attempt to index global 'self' (a nil value)

Still investigating ...
Reply | Threaded
Open this post in threaded view
|

LuaSoap corrected (was : LuaSoap 3.0 vs Lua 5.1)

Laurent FAILLIE
Hi all,

So I found where the problem was : both functions list_children() and decode() were wrong.

Working versions are the following :

----
-- Iterates over the children of an object.
-- It will ignore any text, so if you want all of the elements, use ipairs(obj).
-- @param obj Table (LOM format) representing the XML object.
-- @param tag String with the matching tag of the children
--    or nil to match only structured children (single strings are skipped).
-- @return Function to iterate over the children of the object
--    which returns each matching child.

local function list_children (obj, tag)
    local i = 0
    return function ()
        i = i+1
        local v = obj[i]
        while v do
            if type(v) == "table" and (not tag or v.tag == tag) then
                return v
            end
            i = i+1
            v = obj[i]
        end
        return nil
    end
end

---------------------------------------------------------------------
-- Converts a SOAP message into Lua objects.
-- @param doc String with SOAP document.
-- @return String with namespace, String with method's name and
--    Table with SOAP elements (LuaExpat's format).
---------------------------------------------------------------------
local function decode (doc)
    local obj = assert (parse (doc))
    local ns = obj.tag:match ("^(.-):")
    assert (obj.tag == ns..":Envelope", "Not a SOAP Envelope: "..
        tostring(obj.tag))
    local namespace = find_xmlns (obj.attr)
    local lc = list_children (obj)
    local o = lc ()
    -- Skip SOAP:Header
    while o and (o.tag == ns..":Header" or o.tag == "SOAP-ENV:Header") do
        o = lc ()
    end
    if o.tag == ns..":Body" or o.tag == "SOAP-ENV:Body" then
        lc = list_children (o)
        obj = lc ()
    else
        error ("Couldn't find SOAP Body!")
    end
    local method = obj.tag:match ("%:([^:]*)$") or obj.tag

    local entries = {}
    for i = 1, #obj do
        for j = 1, #obj[i] do    -- remove noisy CR fake entries
            if obj[i][j] == "\n" then
                table.remove(obj[i],j)
                j = j-1
            end
        end
        entries[i] = obj[i]
    end
    return namespace, method, entries
end
----

I found a problem as well with luaexpat (1.2.0-1). It treats Carriage returns as string and not as space and consequently creating some noisy entries in the resulting array.
As example

---
<SOAP-ENV:Body>[CR]
<ser-root:CheckEntryPointsResponse xmlns:ser-root="http://eux932.sgp.st.com/STAdminMisc/StopB2BProcessing/CheckEntryPointsWS"><ErrorMessages>[CR]
<ArrayOfstringItem>Port FilePollingListener:/home/wmadm/usr/laurent/tst is disabled</ArrayOfstringItem>[CR]
<ArrayOfstringItem>Task STAdmin.purge:purgeISData is suspended</ArrayOfstringItem>[CR]
---

create something like :

---
{
  "
"
  {
    {
      "
"
      {
        "Port FilePollingListener:/home/wmadm/usr/laurent/tst is disabled"
        {
        }
        tag = "ArrayOfstringItem"
      }
      "
"
      {
        "Task STAdmin.purge:purgeISData is suspended"
        {
        }
        tag = "ArrayOfstringItem"
      }
      "
"
      {
        "SAPListener STSAPResource.B2BCRM.listener:B2BCRM is NOT enabled"
        {
        }
        tag = "ArrayOfstringItem"
      }
      {
      }
      tag = "ErrorMessages"
    }
    {
      "xmlns:ser-root"
      xmlns:ser-root = "http://eux932.sgp.st.com/STAdminMisc/StopB2BProcessing/CheckEntryPointsWS"
    }
    tag = "ser-root:CheckEntryPointsResponse"
  }
  {
  }
  tag = "SOAP-ENV:Body"
}
---

(notice the "[CR]" rows for each [CR] in the source.
I put some code to remove them in decode() but it looks for me a bug in luaexpat or in libexpat itself.

Bye

Laurent

PS: And after my own investigation, I saw that someone else provided a bug fix as well for the same issue ... Anyway, my code is still valid due to expat problem ...
Reply | Threaded
Open this post in threaded view
|

Re: LuaSoap 3.0 vs Lua 5.1

Tomás Guisasola-2
In reply to this post by Laurent FAILLIE
  Hi Laurent

On Tue, 10 Jul 2012, Laurent FAILLIE wrote:
> Do you have any idea when you will be able to release LuaSoap 3.0 and
> if it will be compatible with Lua 5.1 ?
  No, I don't have an idea yet.
  Yes, it will be compatible with Lua 5.1 (it already is :-)
It will be also compatible with Lua 5.2.

  Regards,
  Tomás
Reply | Threaded
Open this post in threaded view
|

Re: LuaSoap 3.0 vs Lua 5.1

Tomás Guisasola-2
In reply to this post by Laurent FAILLIE
  Hi Laurent

On Tue, 10 Jul 2012, Laurent FAILLIE wrote:
> Now, 3.0 install is not 5.1 compliant : to make it working, you have to
>
> cd /usr/local/share/lua/5.1/ ln soap.lua init.lua
  I think this is a problem with your package.path...
  Tomás
Reply | Threaded
Open this post in threaded view
|

Re: LuaSoap corrected (was : LuaSoap 3.0 vs Lua 5.1)

Tomás Guisasola-2
In reply to this post by Laurent FAILLIE
  Hi Laurent

  I'm sorry but I'm very busy these days.  I already have some
improvements made but not added to Github.  I'll try to find some time
to commit all of them and release a final version.

On Wed, 11 Jul 2012, Laurent FAILLIE wrote:
> I found a problem as well with luaexpat (1.2.0-1). It treats Carriage
> returns as string and not as space and consequently creating some noisy
> entries in the resulting array.
  Yes, I know that, but I thought it was correct behavior.  Is there
any doc that states that we can omit any CR inside an XML document?
I know many times we don't want them, but I think this is not Expat's
problem, since it is supposed to read any XML document.  Anyway, I am
not sure if SOAP defines we can ignore "lone CR's between tags" (which
is what you're skipping).  I prefer to add a parameter to ignore them
or something that let this decision to the programmer.
  Anyway, thanks for the report (a diff would be sufficient :-)
  Tomás
Reply | Threaded
Open this post in threaded view
|

Re: LuaSoap corrected (was : LuaSoap 3.0 vs Lua 5.1)

Jay Carlson
In reply to this post by Laurent FAILLIE
On Jul 11, 2012, at 10:36 AM, Laurent FAILLIE wrote:

> I found a problem as well with luaexpat (1.2.0-1). It treats Carriage returns as string and not as space and consequently creating some noisy entries in the resulting array.
> As example
>
> ---
> <SOAP-ENV:Body>[CR]
> <ser-root:CheckEntryPointsResponse xmlns:ser-root="http://eux932.sgp.st.com/STAdminMisc/StopB2BProcessing/CheckEntryPointsWS"><ErrorMessages>[CR]
> <ArrayOfstringItem>Port FilePollingListener:/home/wmadm/usr/laurent/tst is disabled</ArrayOfstringItem>[CR]
> <ArrayOfstringItem>Task STAdmin.purge:purgeISData is suspended</ArrayOfstringItem>[CR]
> ---
>
> create something like :
>
> ---
> {
>   "
> "
>   {

This is not a bug in luaexpat; in fact this behavior is specifically documented. The last sentence of http://matthewwild.co.uk/projects/luaexpat/lom.html :

|   Note that even the new-line and tab characters are stored on the table.

This is proper behavior for a general XML processor. See XML 1.0 5e, Section 2.10: White Space Handling ( http://www.w3.org/TR/REC-xml/#sec-white-space )

> An XML processor MUST always pass all characters in a document that are not markup through to the application.

(expat is not a validating XML processor, so the next sentence of the specification does not apply.)

If you do not want mixed content, the right place to handle it is in a LOM tree builder; after you see the first start child tag event inside an element, you can delete any preceding whitespace, and start ignoring any whitespace character data until the element closes. Better, assert() any character data is whitespace before ignoring it--this will catch violations of no-mixed-content.

The big misfeature (or bug) in LuaExpat is reporting attributes by both name and order. Order of attributes cannot be significant in XML, and having those numeric values there means pairs() can't be used to iterate over attributes. The first thing I do when receiving start tag events is nuke the damn array-part.

Jay
Reply | Threaded
Open this post in threaded view
|

Re: LuaSoap 3.0 vs Lua 5.1

Laurent FAILLIE
In reply to this post by Tomás Guisasola-2
Hi Tomas,

Don't worry about space, as per Jay's response, it's a normal behavior so I'll  handle that in my own code.

As soon as I patched LuaSoap 3.0, it is perfectly working with Lua5.1 ... providing I changed as well soap.lua to init.lua

>  I think this is a problem with your package.path...

Hum, I'm still using Lua as it was packaged in my distribution (Gentoo) and I haven't changed any path as far I reminder :

$ luarocks path
export LUA_PATH='/usr/local/share/lua/5.1//?.lua;/usr/local/share/lua/5.1//?/init.lua;/home/laurent/.luarocks/share/lua/5.1//?.lua;/home/laurent/.luarocks/share/lua/5.1//?/init.lua;/usr/local/share/lua/5.1//?.lua;/usr/local/share/lua/5.1//?/init.lua;./?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;/usr/local/lib/lua/5.1/?.lua;/usr/local/lib/lua/5.1/?/init.lua;/usr/share/lua/5.1/?.lua;/usr/share/lua/5.1/?/init.lua'
export LUA_CPATH='/usr/local/lib/lua/5.1//?.so;/home/laurent/.luarocks/lib/lua/5.1//?.so;./?.so;/usr/local/lib/lua/5.1/?.so;/usr/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so'

I did also a test installation with Lua5.2 and I got the same path :

$ ~/lua52/bin/luarocks path
export LUA_PATH='/home/laurent/lua52/share/lua/5.2/?.lua;/home/laurent/lua52/share/lua/5.2/?/init.lua;/home/laurent/lua52/share/lua/5.2//?.lua;/home/laurent/lua52/share/lua/5.2//?/init.lua;/home/laurent/lua52/share/lua/5.2/?.lua;/home/laurent/lua52/share/lua/5.2/?/init.lua;/home/laurent/lua52/lib/lua/5.2/?.lua;/home/laurent/lua52/lib/lua/5.2/?/init.lua;./?.lua'
export LUA_CPATH='/home/laurent/lua52/lib/lua/5.2/?.so;/home/laurent/lua52/lib/lua/5.2/?.so;/home/laurent/lua52/lib/lua/5.2/loadall.so;./?.so'

Bye

Laurent