Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing node parameters in named templates using XSLT 2.0
    text
    copied!<p>I am attempting to use XSLT 2.0 to generate a XHTML view of content encoded in RDF/XML. I would like to use named templates to modularize and simply my XSL stylesheet.</p> <p>My initial attempt to pass nodes to my named templates is clearly not working.</p> <p>I am new to XSLT, but web searches have led me to believe my problem is because XSL is passing a result tree fragment (RTF) instead of a node. This is definitely an issue with XSLT 1.0, but is it an issue with 2.0? Unfortunately, it is non-obvious to me how to apply solutions posed to XSL node-passing question on stackoverflow and similar sites.</p> <p>Is what I want to do even possible with XSLT 2.0?</p> <p>What direction should I take?</p> <pre><code>&lt;xsl:template match="rdf:RDF"&gt; &lt;xsl:variable name="report" select="owl:NamedIndividual[@rdf:about='&amp;ex;quality_report']"/&gt; &lt;table&gt; &lt;tr&gt; &lt;xsl:for-each select="owl:NamedIndividual[@rdf:about=$report/mdsa:hasProductScope/@rdf:resource]"&gt; &lt;td&gt; &lt;xsl:call-template name="quality_label"&gt; &lt;xsl:with-param name="product_scope" select="."/&gt; &lt;/xsl:call-template&gt; &lt;/td&gt; &lt;/xsl:for-each&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/xsl:template&gt; &lt;xsl:template name="quality_label"&gt; &lt;xsl:param name="product_scope"/&gt; &lt;table&gt; &lt;xsl:for-each select="owl:NamedIndividual[@rdf:about=$product_scope/mdsa:scopeDataEntity/@rdf:resource]"&gt; &lt;tr&gt;&lt;td&gt; &lt;!-- CALL ANOTHER NAMED TEMPLATE TO PROCESS DATA ENTITY --&gt; &lt;/td&gt;&lt;/tr&gt; &lt;/xsl:for-each&gt; &lt;/table&gt; &lt;/xsl:template&gt; </code></pre> <p>I also tried it with</p> <pre><code>&lt;xsl:with-param name="entity" select="current()"/&gt; </code></pre> <p>example RDF/XML</p> <pre><code> &lt;owl:NamedIndividual rdf:about="&amp;ex;modis_aqua_aod_product_scope"&gt; &lt;rdf:type rdf:resource="&amp;mdsa;ProductScope"/&gt; &lt;mdsa:scopeDataEntity rdf:resource="&amp;ex;modis_aqua_global_data_entity"/&gt; &lt;mdsa:scopeDataEntity rdf:resource="&amp;ex;modis_aqua_global_land_only_data_entity"/&gt; &lt;mdsa:scopeDataEntity rdf:resource="&amp;ex;modis_aqua_e_conus_data_entity"/&gt; &lt;mdsa:scopeDataEntity rdf:resource="&amp;ex;modis_aqua_w_conus_data_entity"/&gt; &lt;mdsa:scopeDataEntity rdf:resource="&amp;ex;modis_aqua_central_america_data_entity"/&gt; &lt;mdsa:scopeDataEntity rdf:resource="&amp;ex;modis_aqua_south_america_data_entity"/&gt; &lt;mdsa:scopeDataEntity rdf:resource="&amp;ex;modis_aqua_s_south_america_data_entity"/&gt; &lt;mdsa:scopeDataEntity rdf:resource="&amp;ex;modis_aqua_africa_above_equator_data_entity"/&gt; &lt;mdsa:scopeDataEntity rdf:resource="&amp;ex;modis_aqua_equatorial_africa_data_entity"/&gt; &lt;mdsa:scopeDataEntity rdf:resource="&amp;ex;modis_aqua_africa_below_equator_data_entity"/&gt; &lt;mdsa:scopeDataEntity rdf:resource="&amp;ex;modis_aqua_europe_mediterranean_data_entity"/&gt; &lt;mdsa:scopeDataEntity rdf:resource="&amp;ex;modis_aqua_eurasian_boreal_data_entity"/&gt; &lt;mdsa:scopeDataEntity rdf:resource="&amp;ex;modis_aqua_east_asia_midlatitudes_data_entity"/&gt; &lt;mdsa:scopeDataEntity rdf:resource="&amp;ex;modis_aqua_peninsular_southeast_asia_data_entity"/&gt; &lt;mdsa:scopeDataEntity rdf:resource="&amp;ex;modis_aqua_indian_subcontinent_data_entity"/&gt; &lt;mdsa:scopeDataEntity rdf:resource="&amp;ex;modis_aqua_australian_continent_data_entity"/&gt; &lt;mdsa:scopeVariable rdf:resource="urn:nasa:eosdis:variable:MYD08_D3.051:Optical_Depth_Land_And_Ocean_Mean"/&gt; &lt;/owl:NamedIndividual&gt; &lt;owl:NamedIndividual rdf:about="&amp;ex;quality_report"&gt; &lt;rdf:type rdf:resource="&amp;mdsa;QualityReport"/&gt; &lt;dcterms:identifier rdf:datatype="http://www.w3.org/2001/XMLSchema#string"&gt;01ffc5bfba33e7139ffbd4b7185f9b0e&lt;/dcterms:identifier&gt; &lt;mdsa:hasProductScope rdf:resource="&amp;ex;modis_terra_aod_product_scope"/&gt; &lt;mdsa:hasProductScope rdf:resource="&amp;ex;modis_aqua_aod_product_scope"/&gt; &lt;/owl:NamedIndividual&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload