在xml中声明和使用变量
嗨,我想声明一个变量,并使用它在XML中设置为属性在xml中声明和使用变量,xml,xslt,Xml,Xslt,嗨,我想声明一个变量,并使用它在XML中设置为属性 我是这样使用这个变量的 <param name="namelist" split="," max-occurrences="&count;" max-len="1000"/> 有人能说这样做的正确方法吗。 目的是我应该有一个count值,它将在xml文件的许多地方使用。 因为我是XML新手,所以建议我在一些网站上学习XML变量。 <?xml version="1.0"?> <xsl:stylesh
我是这样使用这个变量的
<param name="namelist" split="," max-occurrences="&count;" max-len="1000"/>
有人能说这样做的正确方法吗。
目的是我应该有一个count值,它将在xml文件的许多地方使用。
因为我是XML新手,所以建议我在一些网站上学习XML变量。
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
<xsl:param name='count'>28</xsl:param>
<xsl:template match="/">
<xml>
<xsl:element name='param>
<xsl:attribute name='name'>namelist</xsl:attribute>
<xsl:attribute name='split'>,</xsl:attribute>
<xsl:attribute name='max-occurrences'><xsl:value-of select='$count'/></xsl:attribute>
<xsl:attribute name='max-len'>100</xsl:attribute>
</xsl:element>
</xml>
</xsl:template>
</xsl:stylesheet>
28
我们不能内联设置这些属性而不是这样做吗?
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
<xsl:param name='count'>28</xsl:param>
<xsl:template match="/">
<xml>
<param name='namelist' split=',' max-len='100'>
<xsl:attribute name='max-occurrences'><xsl:value-of select='$count'/></xsl:attribute>
</param>
</xml>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
<xsl:param name='count'>28</xsl:param>
<xsl:template match="/">
<xml>
<param name='namelist' split=',' max-len='100' max-occurrences='{$count}'/>
</xml>
</xsl:template>
</xsl:stylesheet>