Skip to content

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

@manstis

Description

@manstis

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions