question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

com.gargoylesoftware.htmlunit.javascript.host.xml.XMLSerializer ignores xsl:output

See original GitHub issue

Hi,

I notice that com.gargoylesoftware.htmlunit.javascript.host.xml.XMLSerializer ignores any output options defined however it may simply be my understanding or my environment and others with a better understanding able to guide me to a solution or clarify my understanding.

I am running HtmlUnit indirectly through a Google Web Toolkit (GWT) GWTTestCase that uses HtmlUnit internally… (so my ability to change to a different version of HtmlUnit is more difficult, if needed). That aside how HtmlUnit is instantiated should have little influence on the issue.

During my debugging I notice com.gargoylesoftware.htmlunit.javascript.host.xml.XSLTProcessor is looking up a Xalan XSLTProcessor that correctly contains the same output settings defined in the XSLT after instantiation and transformation to a Element. However com.gargoylesoftware.htmlunit.javascript.host.xml.XMLSerializer ignores the output settings and writes the string to a single un-indented line.

My XLST (additional settings taken from here)

<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" ',
    xmlns:xalan="http://xml.apache.org/xalan" >
  <xsl:output indent="yes" xalan:indent-amount="2" />

My usage from JS

var xlstProcessor = new XSLTProcessor(xslt);
var xmlResult = xlstProcessor.transformToDocument(xmlDocument);
new XMLSerializer().serializeToString(xmlResult);

When ran in a real browser this returns a formatted (indents and multi-line) string.

Any pointers or help very much appreciated.

With kind regards,

Mike

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
rbricommented, Jan 14, 2020

Great will have a look at this tomorrow

0reactions
rbricommented, Feb 8, 2020

Sorry for the missing comment here, this is implemented with the latest release. Please check and open a new issue if you still have problems with this.

Again sorry for missing this update.

Read more comments on GitHub >

github_iconTop Results From Across the Web

com.gargoylesoftware.htmlunit.javascript.host.xml.XMLSerializer ...
Contains the XML representation of the node and all its descendants. * @return an XML representation of this node and all its descendants...
Read more >
Changes - HtmlUnit - SourceForge
NamedNodeMap moved from com.gargoylesoftware.htmlunit.javascript to ... Ignore invalid css selectors (inside pseudo not) instead of throwing an exception.
Read more >
java htmlunit failing to load Javascript - Stack Overflow
What is causing this error, and how do I fix it? WebClient webClient = new WebClient(); HtmlPage page = ...
Read more >
XmlSerializer ignores XmlIgnore attributes for reintroduced or ...
there seems to be a bug in XmlSerializer it doesn't respect [XmlIgnore] at hidden (reintroduced with new) or overriden property - see ...
Read more >
XmlAttributes.XmlIgnore Property (System.Xml.Serialization)
Gets or sets a value that specifies whether or not the XmlSerializer serializes a public field or public read/write property.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found