我有一个字符串在一个节点,我想拆分上的字符串’?并返回数组中的最后一项。
例如,在下面的块中:
<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()
使用递归方法:
原文链接:https://www.f2er.com/vb/256417.html<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>