xml - XSL value-of returns no match -


alright trying convert xhtml document rdf/xml (don't ask, it's assignment) using xslt information rdf file located in meta tags in xhtml document. have first xpath query done locate value of about attribute of <rdf:description>. tested xpath query on separate website returned proper result. however, when try incorporate in xslt result empty string.

i'm looking nudge in right direction. don't see i'm wrong. here's example xhtml document.

<?xml version="1.0" encoding="iso-8859-1" ?> <?xml-stylesheet href="tn6_q6.xsl" type="text/xsl" ?> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en"     "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">   <head>     <link rel="schema.dc" href="http://purl.org/dc/elements/1.1/" />     <meta name="dc.title" content="le titre de mon document" />     ...     <title>...</title>   </head>   <body>     ...   </body> </html> 

that's xslt have built far. know looks awful again... that's assignment.

<?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"     xmlns:xhtml="http://www.w3.org/1999/xhtml"> <xsl:template match="*"> <html><body><pre> &lt;?xml version="1.0" encoding="iso-8859-1" ?&gt; &lt;rdf:rdf xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" &gt; &lt;rdf:description rdf:about="    <!-- line -->   <xsl:value-of select="html/*[local-name()='head']/*[local-name()='link']/@href"/>"&gt;  &lt;/rdf:description&gt; &lt;/rdf:rdf&gt; </pre></body></html> </xsl:template> </xsl:stylesheet> 

you can test xpath right here: http://www.xpathtester.com/saved/85785aab-0449-472e-a94f-77ee49d4e330

your template matches "*" context node when value-of evaluated root html element. therefore need start path head:

<xsl:value-of select="*[local-name()='head']/*[local-name()='link']/@href"/> 

or better local-name() trick use fact you've declared namespace in <xsl:stylesheet> , use corresponding qualified names in path:

<xsl:value-of select="xhtml:head/xhtml:link/@href" /> 

you might consider changing template match="/" instead of match="*", in case context document root node rather html element, need add html front of path:

<xsl:value-of select="xhtml:html/xhtml:head/xhtml:link/@href" /> 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -