SORU
25 EYLÜL 2008, PERŞEMBE


XSLT bir Bölme var() fonksiyonu?

Bir düğüm, bir dize ve dize bölmek istiyorum '?' ve dizinin son öğeyi döndürür.

Blok aşağıda örneğin:

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

someNode değeri bölmek istiyorum.

Edit: İşte Asp.Net benim sayfa için Xsl yük ... 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()

Güncelleme:burada an example of splitting XML on a particular node

CEVAP
26 EYLÜL 2008, Cuma


Özyinelemeli yöntemi kullanın:

<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>

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • After Effects Tutorials w/ Mikey

    After Effect

    24 HAZİRAN 2009
  • Chip Johnson

    Chip Johnson

    30 AĞUSTOS 2007
  • SalGames2016

    SalGames2016

    17 Kasım 2012