XSLT是否具有Split()函数?

我在节点中有一个字符串,我想将字符串拆分为'?' 并返回数组中的最后一项。


例如,在下面的块中:


<a>

    <xsl:attribute name="href">

        /newpage.aspx?<xsl:value-of select="someNode"/>

    </xsl:attribute>

    Link text

</a>

我想分割someNode价值。


编辑:这是我用来为我的Asp.Net页面加载Xsl的VB.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()


慕的地6264312
浏览 837回答 3
3回答

动漫人物

使用递归方法:<xsl:template name="output-tokens">&nbsp; &nbsp; <xsl:param name="list" />&nbsp;&nbsp; &nbsp; <xsl:variable name="newlist" select="concat(normalize-space($list), ' ')" />&nbsp;&nbsp; &nbsp; <xsl:variable name="first" select="substring-before($newlist, ' ')" />&nbsp;&nbsp; &nbsp; <xsl:variable name="remaining" select="substring-after($newlist, ' ')" />&nbsp;&nbsp; &nbsp; <id>&nbsp; &nbsp; &nbsp; &nbsp; <xsl:value-of select="$first" />&nbsp;&nbsp; &nbsp; </id>&nbsp; &nbsp; <xsl:if test="$remaining">&nbsp; &nbsp; &nbsp; &nbsp; <xsl:call-template name="output-tokens">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <xsl:with-param name="list" select="$remaining" />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; </xsl:call-template>&nbsp; &nbsp; </xsl:if></xsl:template>

慕田峪7331174

我最终使用了这个substring-after()功能。这对我有用:<a>&nbsp; &nbsp; <xsl:attribute name="href">&nbsp; &nbsp; &nbsp; &nbsp; /newpage.aspx?<xsl:value-of select="substring-after(someNode, '?')"/>&nbsp; &nbsp; </xsl:attribute>&nbsp; &nbsp; Link text</a>即使将我的XSLT版本设置为2.0,我仍然'tokenize()' is an unknown XSLT function.在尝试使用时出现“ ”错误tokenize()。
打开App,查看更多内容
随时随地看视频慕课网APP