.net – XSLT有一个Split()函数吗?

前端之家收集整理的这篇文章主要介绍了.net – XSLT有一个Split()函数吗?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个字符串在一个节点,我想拆分上的字符串’?并返回数组中的最后一项。

例如,在下面的块中:

<a>
    <xsl:attribute name="href">
        /newpage.aspx?<xsl:value-of select="someNode"/>
    </xsl:attribute>
    Link text
</a>

我想拆分someNode值。

编辑:
这里是VB.Net,我用来加载Xsl为我的Asp.Net页面

Dim xslDocPath As String = HttpContext.Current.Server.MapPath("~/App_Data/someXslt.xsl")
Dim myXsltSettings As New XsltSettings()
Dim myXMLResolver As New XmlUrlResolver()

myXsltSettings.EnableScript = True
myXsltSettings.EnableDocumentFunction = True

myXslDoc = New XslCompiledTransform(False)
myXslDoc.Load(xslDocPath,myXsltSettings,myXMLResolver)

Dim myStringBuilder As New StringBuilder()
Dim myXmlWriter As XmlWriter = Nothing

Dim myXmlWriterSettings As New XmlWriterSettings()
myXmlWriterSettings.ConformanceLevel = ConformanceLevel.Auto
myXmlWriterSettings.Indent = True
myXmlWriterSettings.OmitXmlDeclaration = True

myXmlWriter = XmlWriter.Create(myStringBuilder,myXmlWriterSettings)

myXslDoc.Transform(xmlDoc,argumentList,myXmlWriter)

Return myStringBuilder.ToString()

更新:这里是an example of splitting XML on a particular node

使用递归方法
<xsl:template name="output-tokens">
    <xsl:param name="list" /> 
    <xsl:variable name="newlist" select="concat(normalize-space($list),' ')" /> 
    <xsl:variable name="first" select="substring-before($newlist,' ')" /> 
    <xsl:variable name="remaining" select="substring-after($newlist,' ')" /> 
    <id>
        <xsl:value-of select="$first" /> 
    </id>
    <xsl:if test="$remaining">
        <xsl:call-template name="output-tokens">
            <xsl:with-param name="list" select="$remaining" /> 
        </xsl:call-template>
    </xsl:if>
</xsl:template>
原文链接:https://www.f2er.com/vb/256417.html

猜你在找的VB相关文章