XML : How to display XSL attributes on XML

I have added attributes on my XML and I need to edit XSL file to be able to display car attributes, how can I edit to be able to see it on XML. This is my XML:

  <?xml version = "1.0"  encoding = "utf-8" ?>  <?xml-stylesheet type = "text/xsl" href = "7.5.xsl" ?>  <CarCatalog>      <CarItem>          <make>Nissan</make>          <model>Altima</model>          <year>2016</year>          <color>Red</color>          <engine>              <number_of_cylinders>6</number_of_cylinders>              <fuel_system>fuel</fuel_system>          </engine>          <number_of_doors>4</number_of_doors>          <transmission_type>Auto</transmission_type>          <accessories radio="Yes" air_conditioning="Yes" power_windows="Yes" Power_steering="Yes" Power_brakes="No" />      </CarItem>  </CarCatalog>  

This is XSL part:

  <?xml version="1.0" encoding="utf-8" ?>  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">        <xsl:template match="CarCatalog">            <xsl:for-each select="CarItem">              <span style="font-style: italic; color: blue;"> Year: </span>              <xsl:value-of select="year" />              <br />              <span style="font-style: italic; color: blue;"> Make: </span>              <xsl:value-of select="make" />              <br />              <span style="font-style: italic; color: blue;"> Model: </span>              <xsl:value-of select="model" />              <br />              <span style="font-style: italic; color: blue;"> Color: </span>              <xsl:value-of select="color" />              <br />              <span style="font-style: italic; color: blue;"> Engine: </span>              <xsl:value-of select="engine" />              <br />              <span style="font-style: italic; color: blue;"> Number of doors: </span>              <xsl:value-of select="number_of_doors" />              <br />              <span style="font-style: italic; color: blue;"> Transmission type: </span>              <xsl:value-of select="transmission_type" />              <br />     <!-- Here I got stock -->                       <span style="font-style: italic; color: blue;"> Radio: </span>              <xsl:attribute name="accessories">                  <xsl:value-of select="." />              </xsl:attribute>                  <br />              <br />          </xsl:for-each>      </xsl:template>  </xsl:stylesheet>  

Thank you advance I was trying different methods but I can't make it work.

No comments:

Post a Comment