我正在做一個批處理的xsl轉換,想用我的樣式表中的一個引數來形成輸出檔案名,但我相當不確定如何做,應該是這樣的:
$output = Join-Path $mypath{{XPATH}}. $file.Name
java -cp $saxonpath net.sf.saxon.Transform -t -s:$file -xsl:$xsltpath -o:$output >。
(用{{XPATH}}指的是我的XPATH,簡單的說就是count(//error))
希望有人能幫我解決這個問題。z 謝謝!
uj5u.com熱心網友回復:
不要用-o:$output來定義一個輸出。
你可以把你的輸出路徑作為一個引數傳遞給你的轉換,并使用xsl:result-document來創建你的輸出檔案。
沿著這些路線的東西 :
$output = Join-Path $mypath $file.Name
java -cp $saxonpath net.sf.saxon.Transform -t -s:$file -xsl:$xsltpath -mypath=$output
<xsl:styleheet>
...
<xsl:param name="mypath"/span>/>
...
<xsl:result-document href="concat($mypath,count(//error))" method="xml"/span>>。
...
</xsl:result-document>
</xsl:樣式表>。
根據你的系統,你需要謹慎對待路徑中使用的分隔符。
uj5u.com熱心網友回復:
如果你想在運行XSLT之前進行XPath評估,以計算例如該計數,那么就用e.g.呼叫XQuery處理器
。java -cp $saxonpath net.sf.saxon. 查詢 -qs:'count(//error)' -s:$file '! method=text'
例如,將其存盤在一個變數中
。count=`java -cp $saxonpath net. sf.saxon.Query -qs:'count(//*)' -s:$file '! method=text'`。
或者,在你的原始版本中,可能
$output = Join-Path $mypath `java -cp $saxonpath net. sf.saxon.Query -qs:'count(//*)' -s:$file ' !method=text'` $file.Name
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/324977.html
標籤:
