Checking the value of a variable inside a variable with a higher degree of probability in XSLT

I need to be able to verify that the "current" value of a variable is inside the override of the same variable in another xslt, which includes the other.

main.xslt:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:import href="other.xslt"/>
    <xsl:variable name="email">
        <xsl:if test="string-length($email) = 0">
            bar@foo.com
        </xsl:if>
    </xsl:variable>
    <xsl:template match="/">
        <Email>
            <xsl:value-of select="$email"/>
        </Email>
    </xsl:template>
</xsl:stylesheet>

other.xslt:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:variable name="email">foo@bar.com</xsl:variable>
</xsl:stylesheet>

What I would like to do is to verify that the value of the lower priority variable will be to see if I need to rewrite it in the variable in the current xslt. (disclaimer - the current code will work maliciously)

+3
source share
2 answers

, , , . , , xslt, , , , ( ).

:

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!--                                            -->
  <xsl:import href="other.xsl"/> 
<!--                                            -->
    <xsl:variable name="vMyEmail" select=
     "concat(substring('bar@foo.com', 1 div not($vEmail)), $vEmail)"
     />
<!--                                            -->
    <xsl:template match="/">
      <xsl:value-of select="$vMyEmail"/>
    </xsl:template>
</xsl:stylesheet>

, $vMyEmail , $vEmail ( ), 1 - .

, $vMyEmail . $vEmail .

+3

, , .

: , ( ). , , , , ?

0

All Articles