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

  • Jordie Jordan

    Jordie Jorda

    27 Ocak 2008
  • multimediaGEEKS LLC

    multimediaGE

    3 Mayıs 2010
  • The Slow Mo Guys

    The Slow Mo

    15 AĞUSTOS 2010