Page 1 of 1

preserve format

Posted: Fri Mar 13, 2020 12:00 pm
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.

Re: preserve format

Posted: Wed Mar 25, 2020 5:42 pm
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

Re: preserve format

Posted: Fri Apr 17, 2020 3:51 pm
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

Re: preserve format

Posted: Fri Apr 17, 2020 4:55 pm
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

Re: preserve format

Posted: Mon Jul 06, 2020 5:37 pm
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

Re: preserve format

Posted: Mon Jul 06, 2020 5:53 pm
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