preserve format

Here should go questions about transforming XML with XSLT and FOP.
Oleksii
Posts: 84
Joined: Wed Jul 19, 2017 6:04 pm
Location: Austria
Contact:

preserve format

Post by Oleksii »

Hi,

when using refactoring in oXygen, the formatting is preserved, .e. g. the following example remains the same:

Code: Select all

<zone data="#m1_k589_" lrx="469" lry="1125" type="measure" ulx="321" uly="204" xml:id="zoneOf_measure1"/>
When using an external XSLT and applying it with the transformation scenario, the formatting is changed, the output looks like this:

Code: Select all

<zone data="#m1_k589_"
                  lrx="469"
                  lry="1125"
                  type="measure"
                  ulx="321"
                  uly="204"
                  xml:id="zoneOf_measure1"/>
Is this an XSLT- or oXygen-specific option and is it possible to implement it for XSLT transformations?
Thanks.
Kind regards,
Oleksii Sapov-Erlinger
adrian
Posts: 2855
Joined: Tue May 17, 2005 4:01 pm

Re: preserve format

Post by adrian »

Hello,

The output of an XSLT transformation depends on the XSLT transformer being used and how that transformer is configured to serialize the output. Generally speaking, even an XSLT that just copies the input XML to the output, may have an output with significant changes in the formatting from the input.

What refactoring actions did you use in Oxygen?
Many of the refactoring actions are actually implemented using XQuery Update, not necessarily XSLT.

Regards.
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Oleksii
Posts: 84
Joined: Wed Jul 19, 2017 6:04 pm
Location: Austria
Contact:

Re: preserve format

Post by Oleksii »

Hi Adrian
most often I use "Attributes" and sometimes "Elements". Normally, I use Saxon PE 9.8, is it possible to configure it that way in oXygen?
best regards
Kind regards,
Oleksii Sapov-Erlinger
adrian
Posts: 2855
Joined: Tue May 17, 2005 4:01 pm

Re: preserve format

Post by adrian »

Hi,

It's not possible to configure an XSLT transformation that automatically detects the input XML formatting and keeps the same formatting in the output.
You can manually adjust the formatting/serialization options within the XSLT in the xsl:stylesheet/xsl:output element so that it mimics the formatting of the input XML:
e.g.

Code: Select all

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:saxon="http://saxon.sf.net/">
    <xsl:output method="xml" indent="yes" saxon:indent-spaces="2"/>
Saxon allows fine-tuning the serialization with some extra parameters.
See Saxon - Additional serialization parameters

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Oleksii
Posts: 84
Joined: Wed Jul 19, 2017 6:04 pm
Location: Austria
Contact:

Re: preserve format

Post by Oleksii »

Thank you Adrian,
the indentation works fine but the attributes are still expanded. On a short view, I didn't find the appropriate setting like

Code: Select all

expand-attributes: no
in the Saxon documentation. I wonder how it works in oXygen Refactoring that the format remains the same?
Regards,
Oleksii
Kind regards,
Oleksii Sapov-Erlinger
adrian
Posts: 2855
Joined: Tue May 17, 2005 4:01 pm

Re: preserve format

Post by adrian »

Hi,

Default attributes are expanded at XML parsing time (first step) when building the XML document model.
There is a Saxon option mentioned in the Oxygen documentation, Advanced Saxon HE/PE/EE XSLT Transformation Options
Edit the transformation scenario that you are using (must use Saxon 9.x), press the "Advanced options" (cogwheel) button and clear the box for "Expand attributes defaults (-expand)".

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Post Reply