manoelcampos / xml2lua

XML Parser written entirely in Lua that works for Lua 5.1+. Convert XML to and from Lua Tables 🌖💱
MIT License
290 stars 74 forks source link

lost children data #35

Closed pixeljetstream closed 4 years ago

pixeljetstream commented 4 years ago

Hi, thanks for your project, ran into one issue however when parsing Vulkan's vk.xml

        <command successcodes="VK_SUCCESS" errorcodes="VK_ERROR_TOO_MANY_OBJECTS,VK_ERROR_OUT_OF_HOST_MEMORY">
            <proto><type>VkResult</type> <name>vkGetMemoryWin32HandleKHR</name></proto>
            <param><type>VkDevice</type> <name>device</name></param>
            <param>const <type>VkMemoryGetWin32HandleInfoKHR</type>* <name>pGetWin32HandleInfo</name></param>
            <param><type>HANDLE</type>* <name>pHandle</name></param>
        </command>

serializes wrongly, as the HANDLE section is lost completely

    {
      _attr = {
        errorcodes = "VK_ERROR_TOO_MANY_OBJECTS,VK_ERROR_OUT_OF_HOST_MEMORY",
        successcodes = "VK_SUCCESS"
      } --[[table: 0x01478dc0]],
      param = {
        {
          name = "device",
          type = "VkDevice"
        } --[[table: 0x014798f8]],
        {
          "const",
          "*",
          name = "pGetWin32HandleInfo",
          type = "VkMemoryGetWin32HandleInfoKHR"
        } --[[table: 0x0147a1c0]],
        "*",
      } --[[table: 0x01479958]],
      proto = {
        name = "vkGetMemoryWin32HandleKHR",
        type = "VkResult"
      } --[[table: 0x01479040]]
    } --[[table: 0x01478e50]],
manoelcampos commented 4 years ago

You don't have a regular XML file. These * characters are misplaced.
And you have a const keyword inside a <param> tag, while there is already content for that tag: <type> and <name> tags. In such cases, this const value should be another tag or as a <param>'s attribute.

Even Java XML Parsers such as this one ignores some parts of such an XML. It's no intention of the project to support non-standard XML.

pixeljetstream commented 4 years ago

thanks, will work around by some preprocessing prior parsing, for the patterns it failed