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

Parsing Fragments That Have Namespaces #16

Closed
sorin-ionescu opened this issue Jan 25, 2013 · 3 comments
Closed

Parsing Fragments That Have Namespaces #16

sorin-ionescu opened this issue Jan 25, 2013 · 3 comments

Comments

@sorin-ionescu
Copy link

I am having trouble parsing a document fragment that contains elements with namespaces. When added to a node as children, the namespaces are removed even though the namespaces are defined in the root element of the document to which I wish to add the fragment.

var fragment []byte = foo.Fragment()
fmt.Println(fragment) // prints name spaced elements
node.Child(fragment)
fmt.Println(node) // the elements are added, but the namespaces are removed.

I have also tried to parse the fragment manually with no success in preserving the namespaces.

I have noticed that you are wrapping the fragment with a root element. Nevertheless, the fragment seems to be parsed in the context of a node or document root, which, in my case, has the namespaces defined.

Thank you.

@mdayaram
Copy link
Contributor

Hey sorin, could you give an example of an xml fragment that you're trying to parse that exhibits this behavior?

@zhigangc
Copy link
Contributor

I added a test case

52bf0ac

Wonder if that's what you wanted to do.

@sorin-ionescu
Copy link
Author

I think it's libxml2 at fault here, at least the one that comes with Mac OS X Lion. The latest libxml2 seems to work properly.

@zhigangc zhigangc closed this as completed Feb 5, 2013
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

3 participants