XSLT 应用程序模板模式="@attr"

XSLT applay-template mode="@attr"

是否可以将模板应用于属性? 我编写了一个 XSL,它以正确的顺序打印出地址所在国家/地区的地址。例如:

澳大利亚:

Honorific FirstName LastName
CompanyName
.
.

巴西:

CompanyName
Honorific FirstName LastName

我的 XML 看起来像:

<Addresses locale="AUS">
<Address>
    <Honorific/>
    <FirstName/>
    <LastName/>
    <CompanyName>Name of the Company</CompanyName>
    <CompanyName2/>
    <Address1>Mainstreet 17</Address1>
    <Address2/>
    <PostalCode>59943</PostalCode>
    <City>Somewhere</City>
    <City2/>
    <District/>
    <State/>
</Address>

我的 XML 是从数据库生成的,因此根据我选择的国家/地区,我将获得 0 到 X 个地址。由于有大约 30 种不同的方式来写地址(在不同的国家/地区),我必须将模板应用于每个可能的语言环境。喜欢:

<xsl:template match="/Addresses">
        <xsl:choose>
            <xsl:when test=" @locale='PH' ">
                <xsl:apply-templates mode="PH" />
            </xsl:when>
            <xsl:when test=" @locale='AUS' ">
                <xsl:apply-templates mode="AUS" />
            </xsl:when>
            <xsl:otherwise>
                <xsl:apply-templates mode="#default" />
            </xsl:otherwise>
</xsl:choose>
</xsl:template>

我现在的问题,有没有办法说:

<xsl:apply-templates mode="@locale">

?

或者将语言环境存储在变量中并将其放入我的模式中..

谢谢!

个人模板呢?

<xsl:template match="/Addresses[@locale='PH']">
   ...
</xsl:template>

<xsl:template match="/Addresses[@locale='AUS']">
   ...
</xsl:template>

<xsl:template match="/Addresses">
   ... the default one ...
</xsl:template>