2012-04-03 15 views
0

XSLT 2.0を使用して、RDF/XMLでエンコードされたコンテンツのXHTMLビューを生成しようとしています。 XSLスタイルシートをモジュール化するために、名前付きテンプレートを使用したいと思います。私の名前付きテンプレートにノードを渡すためにXSLT 2.0を使用した名前付きテンプレートのノードパラメータの使用

私の最初の試みは明らかに機能していません。

私はXSLTの新機能ですが、Web検索では、XSLがノードではなく結果ツリーフラグメント(RTF)を渡しているため、Web検索で問題が発生していると考えられています。これは間違いなくXSLT 1.0の問題ですが、2.0の問題ですか?残念ながら、stackoverflowなどのサイトでXSLノードパッシングの問題を解決する方法を適用する方法は私には分かりません。

XSLT 2.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> 

答えて

0

でそれを試してみました、あなたの名前のテンプレートに渡している要素は、フクロウという名前の要素である:namedIndividual。呼び出されたテンプレートはowl:namedIndividualとも呼ばれるこの要素の子を見つけようとしますが、owl:namedIndividual要素にはこの名前の子がありません。

この種の問題は、パラメータと変数の宣言で "as"属性を使用する習慣がある場合、たとえば "= element(owl:namedIndividual)"のように簡単に診断できます。これは、エラーを目立たせ、より良い診断を提供する傾向があります。これをスキーマ認識と組み合わせると、コンパイル時に間違いの通知を受け取ることさえあります。

+0

「スキーマの意識とは何ですか? Stylus StudioのXMLスキーマツールの一部ですか? – LokiPatera

+0

「スキーマ認識」は、このような間違いをより容易に検出できるように、スキーマをインポートし、スタイルシートを最適化し、より良好な型チェックを提供するために、スキーマタイプ定義を利用するスタイルシートを書くためのXSLT 2.0で能力を指します。 –

関連する問題