2009-09-02 7 views
0

私はいくつかのデータを変換しようとしています。私のxmlフィールド "Source/End/Edgecode"に含まれるデータは、-000016のようになります。 先頭のダッシュを削除します。私はabsまたはrightを使うことができると思ったが、私は正しい構文を知らない。 CLIP名から、任意の助け おかげで... *: Xslt abs関数?

<xsl:template name="frame_to_tc"> 
    <xsl:param name="frame"/> 
    <xsl:variable name="hh" select="($frame div $fph)"/> 
    <xsl:variable name="rh" select="($frame mod $fph)"/> 
    <xsl:variable name="mm" select="($rh div $fpm)"/> 
    <xsl:variable name="rm" select="($rh mod $fpm)"/> 
    <xsl:variable name="ss" select="($rm div $fps)"/> 
    <xsl:variable name="rs" select="($rm mod $fps)"/> 
    <xsl:variable name="ff" select="($rs mod $fps)"/> 
    <xsl:value-of select="format-number(floor($hh),'00')"/> 
    <xsl:text>:</xsl:text> 
    <xsl:value-of select="format-number(floor($mm),'00')"/> 
    <xsl:text>:</xsl:text> 
    <xsl:value-of select="format-number(floor($ss),'00')"/> 
    <xsl:text>:</xsl:text> 
    <xsl:value-of select="format-number(floor($ff),'00')"/> 

答えて

1

単純な部分文字列を使用できます。

<xsl:value-of select="substring($yourVariable, 2)"/> 
<!-- In XSLT, the index starts from 1, so here you are taking a substring starting from the second character, in essence, leaving out the hyphen--> 

あるいはノードの代わりに、直接変数..

<xsl:value-of select="substring(/Your/Path/Here, 2)"/> 

あなたが返すように特定の文字数を指定していないので、それは完全に文字列の残りの部分を返します。返される文字数をカンマで区切って制限し、次に切り捨てる長さを指定することができます)例:substring(/Your/Path/Here , 2, 5)

これは5文字までの2番目の文字から切り捨てられます。文字列が "1234567 "23456"を返します。

注:これは、先頭のハイフンのみを削除することを前提としています。先頭のゼロも削除したい場合は、number()の型変換が必要です。前にダッシュを削除する

0

this XPath functionを試してみてください。

このような呼び出し可能
<xsl:value-of select="substring-after($x,'-')"/> 
+0

たらどうなりますか ' - ' が欠落していますか? :) – Thiyagaraj

+0

yeh、これは手の込んだ解決策でした。これは、すべての文字列に - があることを前提としています。 –

1
<xsl:template name="abs"> 
    <xsl:param name="input" select="0"> 

    <xsl:variable name="num" select="number(input)" />  
    <xsl:choose> 
    <xsl:when test="$num &gt;= 0"> 
     <xsl:value-of select="$num" /> 
    </xsl:when> 
    <xsl:when test="$num &lt; 0"> 
     <xsl:value-of select="-1 * $num" /> 
    </xsl:when> 
    <xsl:otherwise> 
     <xsl:value-of select="$input" /> 
    </xsl:otherwise> 
    </xsl:choose> 
<xsl:template> 

<xsl:variable name="absnum"> 
    <xsl:call-template name="abs"> 
    <xsl:with-param name="input" select="some/number" /> 
    </xsl:call-template> 
</xsl:variable> 
関連する問題