Cannot find the script or external object that implements prefix
XSLT 如下:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ms="urn:schemas-microsoft-com:xslt" xmlns:fn="http://www.w3.org/2005/02/xpath-functions">
<xsl:output omit-xml-declaration="yes" method="xml" media-type="text/plain" encoding="utf-8" indent="yes"/>
<xsl:template match="/">
<ROOT>
<PERSONS>
<xsl:for-each select="//ROOT/PERSONS/PERSON" >
<PERSON>
<userid>
<xsl:value-of select="userid"></xsl:value-of>
</userid>
<name>
<xsl:value-of select="name"></xsl:value-of>
</name>
<age>
<xsl:value-of select="age"></xsl:value-of>
</age>
<begindate>
<xsl:value-of select="begindate"></xsl:value-of>
</begindate>
<enddate>
<xsl:value-of select="enddate"></xsl:value-of>
</enddate>
<departmentcode>
<xsl:value-of select="departmentcode"></xsl:value-of>
</departmentcode>
<description>
<xsl:value-of select="description"></xsl:value-of>
</description>
<errorchecking>
<xsl:if test="string-length(userid)>5">user id is too long,</xsl:if>
<xsl:if test="string-length(userid)<5">,</xsl:if>
<xsl:if test="string-length(name)>20">name should be less than 20 characters,</xsl:if>
<xsl:if test="string-length(name)<=20">,</xsl:if>
<xsl:if test="number(age)>150">age should be less than 150,</xsl:if>
<xsl:if test="number(age)<=150">,</xsl:if>
<xsl:variable name="v_year_begin" select="fn:years-from-duration(begindate)"></xsl:variable>
<xsl:variable name="v_month_begin" select="fn:months-from-duration(begindate)"></xsl:variable>
<xsl:variable name="v_day_begin" select="fn:days-from-duration(begindate)"></xsl:variable>
<xsl:variable name="v_year_end" select="fn:years-from-duration(enddate)"></xsl:variable>
<xsl:variable name="v_month_end" select="fn:months-from-duration(enddate)"></xsl:variable>
<xsl:variable name="v_day_end" select="fn:days-from-duration(enddate)"></xsl:variable>
<xsl:if test="ms:format-date(begindate,'yyyy/MMM/dd')=''">begindate format is not correct,</xsl:if>
<xsl:if test="ms:format-date(begindate,'yyyy/MMM/dd')!=''">
<xsl:choose>
<xsl:when test="($v_year_begin>$v_year_end)">begindate can not be later than enddate</xsl:when>
<xsl:otherwise>,</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:if test="ms:format-date(enddate,'yyyy/MMM/dd')=''">enddate format is not correct,</xsl:if>
<xsl:if test="ms:format-date(enddate,'yyyy/MMM/dd')!=''">
<xsl:choose>
<xsl:when test="($v_year_begin>$v_year_end)">enddate can not be early than begindate</xsl:when>
<xsl:otherwise>,</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:variable name="v_code" select="departmentcode"/>
<xsl:choose>
<xsl:when test="/ROOT/DEPARTMENT/code[.=$v_code]"></xsl:when>
<xsl:otherwise>User's departmentcode is not in the department list</xsl:otherwise>
</xsl:choose>
</errorchecking>
</PERSON>
</xsl:for-each>
</PERSONS>
<xsl:copy-of select="//DEPARTMENT"/>
</ROOT>
</xsl:template>
</xsl:stylesheet>
会报这个错误Cannot find the script or external object that implements prefix 'http://www.w3.org/2005/02/xpath-functions'.
我的C#代码是这样的:
XPathDocument xdoc = new XPathDocument(ConfigurationManager.AppSettings["XMLPATH"]);
XslCompiledTransform trans = new XslCompiledTransform();
trans.Load(ConfigurationManager.AppSettings["NewXSLPATH"]);
XmlTextWriter xw = new XmlTextWriter(ConfigurationManager.AppSettings["XMLPATH"], Encoding.UTF8);
xw.Formatting = Formatting.Indented;
trans.Transform(xdoc, null, xw);
xw.Close();
请问该如何解决这个问题啊