1
votes

I'm having trouble rendering html tag from my xml. It comes out as text.

XML:

 <object>
  <output_pid>uk-ac-man-scw:16844</output_pid>
  <output_title>Graphene: exploring carbon flatland</output_title>
  <output_type>Journal article</output_type>
  <output_state>open</output_state>
  <output_createddate>2009-09-25T13:54:34.538Z</output_createddate>
  <output_issueddate>2007</output_issueddate>
  <output_year>2007</output_year>
  <output_citation>A.K. Geim, A.H. MacDonald. (2007). Graphene: exploring carbon flatland. <em>Physics Today</em>, 60(8), 35-41.  eScholarID:<a class="escholarid"
        href="http://www.manchester.ac.uk/escholar/uk-ac-man-scw:16844">16844</a> | DOI:<a class="doi" href="http://dx.doi.org/10.1063/1.2774096">10.1063/1.2774096</a>
  </output_citation>
  <output_journal>Physics Today</output_journal>

XSL (1.0):

<xsl:for-each select="output_citation">
                        <xsl:sort select="//output_createddate"  data-type="text" order="descending"/> 

                        <li>                                
                            <xsl:value-of select="."  />                                   
                           </li>

                    </xsl:for-each>

Output comes out as raw tags and not html formatting:

<li>T. C. Lovejoy, Q. M. Ramasse, M. Falke, A. Kaeppel, R. Terborg, R. Zan, N. Dellby and O. L. Krivanek. (2012). Single atom
     identification by energy dispersive x-ray spectroscopy. Applied Physics Letters, 100(15), 154101.  eScholarID:213891 | DOI:10.1063/1.3701598

  </li>

This is the output that I want (Basically everything within the output_citation tag (not the output_citation tag) with html tags mainatind but excluding the ):

  <li>
     T. C. Lovejoy, Q. M. Ramasse, M. Falke, A. Kaeppel, R. Terborg, R. Zan, N. Dellby and O. L. Krivanek. (2012). Single atom
        identification by energy dispersive x-ray spectroscopy. <em>Applied Physics Letters</em>, 100(15), 154101.  eScholarID:<a class="escholarid" href="http://www.manchester.ac.uk/escholar/uk-ac-man-scw:213891">213891</a> | DOI:<a class="doi" href="http://dx.doi.org/10.1063/1.3701598">10.1063/1.3701598</a>               

  </li>

Also, disable-output-escaping has no effect as there are no CDATA wrapping.

Many thanks

1
I think you need to call <xsl:apply-templates select="."/> instead of <xsl:value-of select="." /> and you need an xsl copy template for all html tags.collapsar

1 Answers

0
votes

As a first step you could use <xsl:copy-of select="node()"/> instead of <xsl:value-of select="." /> as that way you would copy all child nodes. I would however suggest to put an <xsl:apply-templates/> and then to make sure there are other templates like the identity transformation template for the elements you want to copy:

<xsl:template match="@* | node()">
  <xsl:copy>
    <xsl:apply-templates select="@* | node()"/>
  </xsl:copy>
</xsl:template>

Depending on your needs that template might only list the elements you want to copy.

And based on your edit you want

<xsl:template match="/">
  <xsl:apply-templates select="//output_citation"/>
</xsl:template>

<xsl:template match="output_citation">
  <li>
    <xsl:apply-templates/>
  </li>
</xsl:template>

That way, together with first template in this answer, you should get the output you want.