Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用XSLT2.0在命名模板中使用节点参数_Xslt_Xslt 2.0 - Fatal编程技术网

使用XSLT2.0在命名模板中使用节点参数

使用XSLT2.0在命名模板中使用节点参数,xslt,xslt-2.0,Xslt,Xslt 2.0,我试图使用XSLT2.0生成RDF/XML编码内容的XHTML视图。我希望使用命名模板来模块化和简化XSL样式表 我最初试图将节点传递给命名模板的尝试显然不起作用 我不熟悉XSLT,但web搜索让我相信我的问题是因为XSL传递的是结果树片段(RTF),而不是节点。这肯定是XSLT1.0的问题,但它是XSLT2.0的问题吗?不幸的是,如何在stackoverflow和类似站点上应用XSL节点传递问题的解决方案对我来说并不明显 我想用XSLT2.0做的事情可能吗 我该往哪个方向走 <xsl:t

我试图使用XSLT2.0生成RDF/XML编码内容的XHTML视图。我希望使用命名模板来模块化和简化XSL样式表

我最初试图将节点传递给命名模板的尝试显然不起作用

我不熟悉XSLT,但web搜索让我相信我的问题是因为XSL传递的是结果树片段(RTF),而不是节点。这肯定是XSLT1.0的问题,但它是XSLT2.0的问题吗?不幸的是,如何在stackoverflow和类似站点上应用XSL节点传递问题的解决方案对我来说并不明显

我想用XSLT2.0做的事情可能吗

我该往哪个方向走

<xsl:template match="rdf:RDF">
  <xsl:variable name="report" select="owl:NamedIndividual[@rdf:about='&ex;quality_report']"/>
  <table>
    <tr>
      <xsl:for-each select="owl:NamedIndividual[@rdf:about=$report/mdsa:hasProductScope/@rdf:resource]">
        <td>
          <xsl:call-template name="quality_label">
            <xsl:with-param name="product_scope" select="."/>
          </xsl:call-template>
        </td>
      </xsl:for-each>
    </tr>
  </table>
</xsl:template>

<xsl:template name="quality_label">
  <xsl:param name="product_scope"/>
  <table>
    <xsl:for-each select="owl:NamedIndividual[@rdf:about=$product_scope/mdsa:scopeDataEntity/@rdf:resource]">
      <tr><td>
      <!-- CALL ANOTHER NAMED TEMPLATE TO PROCESS DATA ENTITY -->
      </td></tr>
    </xsl:for-each>
  </table>
</xsl:template>

我也试过了

<xsl:with-param name="entity" select="current()"/>

RDF/XML示例

  <owl:NamedIndividual rdf:about="&ex;modis_aqua_aod_product_scope">
    <rdf:type rdf:resource="&mdsa;ProductScope"/>
    <mdsa:scopeDataEntity rdf:resource="&ex;modis_aqua_global_data_entity"/>
    <mdsa:scopeDataEntity rdf:resource="&ex;modis_aqua_global_land_only_data_entity"/>
    <mdsa:scopeDataEntity rdf:resource="&ex;modis_aqua_e_conus_data_entity"/>
    <mdsa:scopeDataEntity rdf:resource="&ex;modis_aqua_w_conus_data_entity"/>
    <mdsa:scopeDataEntity rdf:resource="&ex;modis_aqua_central_america_data_entity"/>
    <mdsa:scopeDataEntity rdf:resource="&ex;modis_aqua_south_america_data_entity"/>
    <mdsa:scopeDataEntity rdf:resource="&ex;modis_aqua_s_south_america_data_entity"/>
    <mdsa:scopeDataEntity rdf:resource="&ex;modis_aqua_africa_above_equator_data_entity"/>
    <mdsa:scopeDataEntity rdf:resource="&ex;modis_aqua_equatorial_africa_data_entity"/>
    <mdsa:scopeDataEntity rdf:resource="&ex;modis_aqua_africa_below_equator_data_entity"/>
    <mdsa:scopeDataEntity rdf:resource="&ex;modis_aqua_europe_mediterranean_data_entity"/>
    <mdsa:scopeDataEntity rdf:resource="&ex;modis_aqua_eurasian_boreal_data_entity"/>
    <mdsa:scopeDataEntity rdf:resource="&ex;modis_aqua_east_asia_midlatitudes_data_entity"/>
    <mdsa:scopeDataEntity rdf:resource="&ex;modis_aqua_peninsular_southeast_asia_data_entity"/>
    <mdsa:scopeDataEntity rdf:resource="&ex;modis_aqua_indian_subcontinent_data_entity"/>
    <mdsa:scopeDataEntity rdf:resource="&ex;modis_aqua_australian_continent_data_entity"/>
    <mdsa:scopeVariable rdf:resource="urn:nasa:eosdis:variable:MYD08_D3.051:Optical_Depth_Land_And_Ocean_Mean"/>
  </owl:NamedIndividual>

  <owl:NamedIndividual rdf:about="&ex;quality_report">
    <rdf:type rdf:resource="&mdsa;QualityReport"/>
    <dcterms:identifier rdf:datatype="http://www.w3.org/2001/XMLSchema#string">01ffc5bfba33e7139ffbd4b7185f9b0e</dcterms:identifier>
    <mdsa:hasProductScope rdf:resource="&ex;modis_terra_aod_product_scope"/>
    <mdsa:hasProductScope rdf:resource="&ex;modis_aqua_aod_product_scope"/>
  </owl:NamedIndividual>

01ffc5bfba33e7139ffbd4b7185f9b0e

传递给命名模板的元素是一个名为owl:namedIndividual的元素。被调用的模板尝试查找此元素的子元素,该子元素也称为owl:namedIndividual,但您的owl:namedIndividual元素没有具有此名称的子元素


如果您养成了在参数和变量声明中使用“as”属性的习惯,例如as=“element(owl:namedIndividual)”,那么这种问题很容易诊断出来。这往往会使错误突出,并提供更好的诊断;如果您将此与模式感知相结合,您甚至会收到错误的编译时通知。

什么是“模式感知”?这是Stylus Studio的XML模式工具的一部分吗?“模式感知”指的是XSLT 2.0中编写样式表的能力,该样式表可以导入模式,并利用模式中的类型定义来优化样式表并提供更好的类型检查,从而更容易地检测此类错误。