Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

XSL match xsl:variable element and change @select attribute

I need to copy a complete xsl-file but change the specific value of the @select attribute of a specific variable.

My pseudocode idea:

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

    <xsl:template match="variable[@name='Name']">
        <xsl:attribute name="select">
            <xsl:value-of select="'new value'"/>
        </xsl:attribute>
    </xsl:template>

To be perfectly clear; how do I select the variable element in a match statement?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

It might be possible with [CDATA] but i prefer a more functional solution.

I am constricted to xslt 1.0.

Any ideas?

>Solution :

how do I select the variable element

Like any other element that’s in namespace, you select it by its qualified name, i.e. a name that includes a prefix bound to the element’s namespace and its local name – for example:

<xsl:template match="xsl:variable[@name='Name']/@select">
    <xsl:attribute name="select">new value</xsl:attribute>
</xsl:template>

Note that your attempt, even if it did work, would remove the name attribute.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading