Reputation: 128
I am new to xslt. I have following xml and xslt which i need to convert into html using XslCompiledTranform. I have following XML
<ref-list id="RL10">
<label>
<bold>7.0</bold>
</label>
<title>
<bold>References</bold>
</title>
<ref id="R66" content-type="references">
<label>2</label>
<mixed-citation publication-type="book">
<person-group person-group-type="author">
<name>
<surname>Chown,</surname>
<given-names>Bill</given-names>
</name>
</person-group>, and
<person-group person-group-type="author">
<name>
<surname>Lange</surname>
<given-names>Michelle</given-names>
</name>
</person-group>. “
<source>Modernizing System Development: Requirements-Based, Model-Driven Design, Implementation and Test</source>.”
<publisher-name>Mentor Graphics Corp., ERTS</publisher-name>,
<month>Feb.</month>
<year>2012</year>.
</mixed-citation></ref>
<ref id="R67" content-type="references">
<label>3</label>
<mixed-citation publication-type="journal">
<person-group person-group-type="author">
<name>
<surname>Blyler,</surname>
<given-names>John</given-names>
</name>
</person-group>. “
<article-title>Model-Driven Development Is Key to Low Power</article-title>.”
<source>Chip Design Magazine - JB’s Circuit</source>,
<month>Dec.</month>
<day>6</day>,
<year>2012</year>.
<uri xlink:href="http://www.chipdesignmag.com/blyler/2012/12/06/model-driven-development-key-to-low-power/">http://www.chipdesignmag.com/blyler/2012/12/06/model-driven-development-key-to-low-power/</uri>.
</mixed-citation>
</ref>
</ref-list>
I have the following xslt
<xsl:template match="ref-list/ref">
<html>
<head></head>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="ref-list/ref">
<p>
<xsl:value-of select="label"/>
<xsl:for-each select="mixed-citation">
<xsl:for-each select="person-group/name">
<xsl:value-of select="given-names"/>
<xsl:value-of select="surnames"/>
</xsl:for-each>
<xsl:text>,</xsl:text>
<xsl:value-of select="source"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="publisher-name"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="day"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="month"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="year"/>
<xsl:text>,</xsl:text>
<xsl:for-each select="uri">
<xsl:value-of select="."/>
</xsl:for-each>
<xsl:text>,</xsl:text>
<xsl:value-of select="article-title"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="publisher-loc"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="volume"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="issue"/>
</xsl:for-each>
</p>
</xsl:template>
I have to transform my xml to html using xslt. But while transforming, it is saying that 'xlink' is an undeclared prefix. I dont know how to parse it. I need the output that parse uri tag having xlink as its attribute.I dont know how to parse any attribute of the any xml tag. Can anyone please explain how to parse any xml tags having its attributes ?
Upvotes: 0
Views: 332
Reputation: 7173
It is called a namespace. The root tag of your xml should contain
xmlns:xlink="http://www.w3.org/1999/xlink
If not it should be included everytime you add xlink:href
in you tag.
Upvotes: 1