Xml 是否可以在xslt变量中指定文档类型值?

Xml 是否可以在xslt变量中指定文档类型值?,xml,xslt-1.0,Xml,Xslt 1.0,我想在如下条件下分配变量值: <xsl:variable name="publicationDoc" select="document(@ID)/tcm:Component/tcm:Data /tcm:Content/em:PublicationData" /> <xsl:variable name="CountryCompId" select="substring-after( $publicationDoc/em:Co

我想在如下条件下分配变量值:

<xsl:variable name="publicationDoc" 
  select="document(@ID)/tcm:Component/tcm:Data
          /tcm:Content/em:PublicationData" />
<xsl:variable name="CountryCompId" 
  select="substring-after(
            $publicationDoc/em:Country/@xlink:href,
            '-')" />

<xsl:variable name="countryIdLocal">
  tcm:<xsl:value-of select="$publicationDoc/em:PubID" 
    />-<xsl:value-of 
    select="substring-after($publicationDoc
              /em:Country/@xlink:href,'-')" />
</xsl:variable>

<xsl:variable name="countryId">
  tcm:<xsl:value-of select="substring-before(
    substring-after($publication,'-'),'-')" 
  />-<xsl:value-of select="substring-after(
     $publicationDoc/em:Country/@xlink:href,'-')" />
</xsl:variable>

<xsl:variable name="countryLocal">
  <xsl:choose>
    <xsl:when test="$CountryCompId != '' ">
      <xsl:value-of select="document(
         $countryIdLocal)/tcm:Component/tcm:Data
         /tcm:Content/em:Country" />
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="''" />
    </xsl:otherwise>
  </xsl:choose>
  </xsl:choose>
</xsl:variable>

<xsl:variable name="country">
  <xsl:choose>
   <xsl:when test="$CountryCompId !='' ">
      <xsl:value-of select="document($countryId)
        /tcm:Component/tcm:Data/tcm:Content/em:Country" />
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="''" />
    </xsl:otherwise>
  </xsl:choose>
</xsl:variable>
//上面我是根据条件赋值的,但是当我尝试转换在路径表达式中使用结果树片段时,它给出了下面的错误,首先使用msxsl:node set函数将其转换为节点集

为变量指定文档类型值似乎不起作用


有什么建议吗?

是否有任何理由不遵循错误消息中给出的建议?在XSLT1.0中,XPath表达式不能针对动态创建的元素进行计算,只能针对输入文档或静态已知的XML进行计算。许多XSLT 1.0处理器实现的节点集扩展允许使用它,但为了使用它,必须调用它,但是,我的变量值变为空。此特定代码片段没有尝试在路径表达式中使用结果树片段-是否确实这是样式表中导致错误的部分?是,问题是,当此变量获得无效数据时,它会在…上出错。转换文档时似乎会出错。只有在使用结果树片段变量时,才会出现此错误消息,即定义xsl:variable的变量有一个body,而不是在/,的最左边有一个select属性,例如:$countryIdLocal/某物。您是否在样式表的其他地方尝试这样做?