こんにちは、Xalanを使ってxslファイルを解析しています。 xslはvb.netパーサーで正しく動作しています。しかし、Xalanはそのxslに対してエラーを出します。JavaスクリプトXSLTエラー:拡張機能で、メソッドjava.lang.Stringが見つかりませんでした。 ([ExpressionContext、] #STRING)
拡張機能について、 方法java.lang.String.FctDateDuration([ExpressionContext、] STRING)を見つけることができませんでした。
ここで私のxslを定義しています。ここで
xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:ttVB="ttVB" exclude-result
XSLに参加を呼び出すJavaスクリプトです: -
<xsl:variable name="start">
xsl:value-of select="substring(DepartureDateTime,1,10)" />
</xsl:variable>
xsl:variable name="end">
xsl:value-of select="substring(following-sibling::OriginDestinationInformation/DepartureDateTime,1,10)" />
</xsl:variable>
xsl:variable name="end1">
xsl:value-of select="substring(preceding-sibling::OriginDestinationInformation/DepartureDateTime,1,10)" />
</xsl:variable>
xsl:variable name="dd" select="ttVB:FctDateDuration(string('2011-02-20'),string('2011-02-25'))"/>
xsl:variable name="dd1" select="ttVB:FctDateDuration(string('2011-02-20'),string('2011-02-25'))"/>
<xsl:choose>
xsl:when test="$dd = 0 or $dd = 1">
<timeQualifier>TA</timeQualifier>
</xsl:when>
xsl:otherwise>
timeQualifier>TD</timeQualifier>
</xsl:otherwise>
</xsl:choose>
ここでは私のJavascript
<msxsl:script language="JavaScript" implements-prefix="ttVB">
<![CDATA[
function FctDateDuration(p_startDate,p_endDate){
if (IsDate(p_startDate) && IsDate(p_endDate)){
FctDateDuration = String(calcDays(p_startDate, p_endDate))
}else{
FctDateDuration = p_startDate + p_endDate
}
return FctDateDuration;
}
function IsDate(ddate){
//alert("Inside IsDate >> "+ddate);
var dteDate;
var year = ddate.substring(0, 4);
var month = ddate.substring(5, 7);
var day = ddate.substring(8,10);
month = month-1;
//alert(year);
//alert(month);
//alert(day);
dteDate=new Date(year,month,day);
return ((day==dteDate.getDate()) && (month==dteDate.getMonth()) && (year==dteDate.getFullYear()));
}
function calcDays(date1,date2){
date1 = date1.split("-");
date2 = date2.split("-");
var sDate = new Date(date1[0]+"/"+date1[1]+"/"+date1[2]);
var eDate = new Date(date2[0]+"/"+date2[1]+"/"+date2[2]);
var daysApart = Math.abs(Math.round((sDate-eDate)/86400000));
//document.getElementById('diffDays').lastChild.data = daysApart;
//alert(daysApart);
return daysApart;
}
]]>
</msxsl:script>
1を参照してください。しかし、答えは混乱です。 * "拡張機能はほとんど移植性がありません" *とはどういう意味ですか? XSLT標準メカニズムに従っている限り、スタイルシートを変更することなく、あるXSLTプロセッサの拡張機能を他のXSLTプロセッサに移植することができます。標準仕様の一部としての拡張機構は、XSLTの機能です! –
MSXML用のJScriptで書かれた拡張機能であるAlejandroは、Xalan用のJavaScriptで書かれた拡張機能や、MicorosftのXslCompiledTransform用のJScript.NETで書かれた拡張機能として移植できるとは限りません。 XSLTからノード集合を取り出し、それを操作してノード集合をXSLTに返す拡張関数を使います。 3つのすべてのXSLTプロセッサの表面にJ(ava)Scriptを使用できるかもしれませんが、XSLTノードセットのスクリプトに公開されているデータタイプとAPIは通常同じではありません。 –
あなたの答えは、これが拡張機能の問題ではないが、標準ではない拡張要素**の問題**がXSLTモデルではない**拡張拡張機能宣言に使用されていることを明確にしていない。 –