Skip to content

Latest commit

 

History

History
68 lines (53 loc) · 1.78 KB

xslt-preprocessing.md

File metadata and controls

68 lines (53 loc) · 1.78 KB

XSLT preprocessing

To maximally leverage the XML interface, an XML style is automatically transformed if an XSLT found. XSLT style can be either embedded into XML style or linked to a standalone file.

Examples

Embedded

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="#my_style"?>
<!DOCTYPE Map [
<!ATTLIST xsl:stylesheet id ID #REQUIRED>
]>
<Map>
    <xsl:stylesheet id="my_style" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
        <xsl:template name="discard_xsl" match="xsl:*">
        </xsl:template>

        <xsl:template match="@*|node()">
            <xsl:copy>
                <xsl:apply-templates select="@*|node()"/>
            </xsl:copy>
        </xsl:template>
    </xsl:stylesheet>

    <Style name="style">
    </Style>
    <Layer name="layer">
        <StyleName>style</StyleName>
    </Layer>
</Map>

Standalone XSL

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet id="my_style" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="style.xsl"?>
<Map>
    <Style name="style">
    </Style>
    <Layer name="layer">
        <StyleName>style</StyleName>
    </Layer>
</Map>

Visual test

Following visual test shows more complicated XSLT, including dynamic evaluation.

xslt-preprocess.xml

xslt-preprocess