Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doubled XML entities #228

Open
scriptin opened this issue May 27, 2017 · 1 comment
Open

Doubled XML entities #228

scriptin opened this issue May 27, 2017 · 1 comment

Comments

@scriptin
Copy link

Example XML:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE test [
<!ENTITY test "test entity">
]>
<test>
  <a>&test;</a>
  <a>&test;</a>
  <a>&test;</a>
</test>

convert.xq:

xquery version "3.0";
module namespace convert = "convert";

declare function convert:convert-entity($text as xs:string) as xs:string? {
  switch($text)
  case "test entity" return "test"
  default return error(xs:QName("unknown-entity"), concat("Unknown entity '", $text, "'"))
};

test.xq:

xquery version "3.0";

import module namespace jx = "http://zorba.io/modules/json-xml";
import module namespace convert = "convert" at "convert.xq";

declare variable $doc external;

jx:xml-to-json(
  <json type="object">
    <pair name="words" type="array">
      { for $word in $doc/test/a
        return <item type="string"> { convert:convert-entity($word/text()) } </item> }
    </pair>
  </json>
)

Run: zorba -i -e doc=test.xml test.xq > test.json

Expected result: JSON file containing an array of 3 strings "test".
Actual result: </home/dmitry/test/convert.xq>:7,18: error [unknown-entity]: Unknown entity 'test entitytest entity'

All entities, starting from a second one encountered during parsing, are parsed as "doubled", i.e. a string is concatenated with itself. In the example above, test entity becomes test entitytest entity.

@scriptin
Copy link
Author

I'm using Ubuntu 16.04.2 LTS

$ zorba -v
Zorba NoSQL Query Processor, Version: 3.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant