XSLT 1 Simple Text Spacing

Using Perl XML :: LibXSLT requires using XSLT 1.0, which means I'm stuck without XSLT 2.0 features. Is there a way in which I can still write text in text form from my processing? I want to:

<values>
    <headers>
        <header>Header 1</header>
        <header>Header 2</header>
    </headers>
    <value>
        <one>First value 1</one>
        <two>First value 2</two>
    </value>
    <value>
        <one>Second value 1</one>
        <two>Second value 2</two>
    </value>
    ....
    <value>
        <one>Nth value 1</one>
        <two>Nth value 2</two>
    </value>
</values>

To become

Header 1          Header 2
First value 1     First value 2
Second value 1    Second value 2
....
Nth value 1       Nth value 2

I understand that XSLT is not necessarily ideal for this type of formatting, but the data will most likely also be formatted in other ways.

+3
source share
1 answer

There is always a “cheap” way to fill in text using a constant line and make a copy of the counter needed for laying, for example:

<xsl:variable name="space" select="'                     '" />
<xsl:variable name="text" select="'Header 1'" />
<xsl:value-of select="concat($text,substring($space,string-length($text)))" />
+2
source

Source: https://habr.com/ru/post/1745816/


All Articles