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

The Mixed Content example for Text Object Conversion does not work. #90

Closed
ghost opened this issue May 25, 2021 · 0 comments
Closed

The Mixed Content example for Text Object Conversion does not work. #90

ghost opened this issue May 25, 2021 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@ghost
Copy link

ghost commented May 25, 2021

Describe the bug
Cannot convert an object with text array ('#'=[]) to XML

To Reproduce
In your documentation you have the following mixed content example
obj2 = { monologue: {
'#': [
'Talk to me Goose!',
{ 'cut': 'dog tag shot' },
'Talk to me...'
]
} }
Attempting to convert it to XML with the following throws an exception:
const doc = xmlBuilder.create().ele(obj2 );
console.log(doc.end({ prettyPrint: true }));

This example throws and exception:
UnhandledPromiseRejectionWarning: InvalidCharacterError: The string contains invalid characters. Invalid XML name: 0
at InvalidCharacterError.DOMException [as constructor] (C:\development\node\XMLMapper\node_modules@oozcitak\dom\lib\dom\DOMException.js:28:28)
at new InvalidCharacterError (C:\development\node\XMLMapper\node_modules@oozcitak\dom\lib\dom\DOMException.js:342:23)
at namespace_validate (C:\development\node\XMLMapper\node_modules@oozcitak\dom\lib\algorithm\NamespaceAlgorithm.js:18:15)
at Object.namespace_extractQName (C:\development\node\XMLMapper\node_modules@oozcitak\dom\lib\algorithm\NamespaceAlgorithm.js:78:5)
at XMLBuilderImpl.ele (C:\development\node\XMLMapper\node_modules\xmlbuilder2\lib\builder\XMLBuilderImpl.js:109:41)
at ObjectReader.BaseReader._element (C:\development\node\XMLMapper\node_modules\xmlbuilder2\lib\readers\BaseReader.js:35:50)
at ObjectReader.BaseReader.element (C:\development\node\XMLMapper\node_modules\xmlbuilder2\lib\readers\BaseReader.js:113:21)
at ObjectReader. (C:\development\node\XMLMapper\node_modules\xmlbuilder2\lib\readers\ObjectReader.js:144:40)
at Object.forEachObject (C:\development\node\XMLMapper\node_modules@oozcitak\util\lib\index.js:106:26)
at ObjectReader._parse (C:\development\node\XMLMapper\node_modules\xmlbuilder2\lib\readers\ObjectReader.js:46:20)

Expected behavior
XML:
<monologue> Talk to me Goose! <cut>dog tag shot</cut> Talk to me... </monologue>

Version:

  • node.js: [v14.17.0]
  • xmlbuilder2 [2.4.1]
@ghost ghost added the bug Something isn't working label May 25, 2021
@ghost ghost assigned oozcitak May 25, 2021
oozcitak added a commit that referenced this issue Jul 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant