XML to XSLT for XML with value in attribute

--------------------------------------------------------------------------------

Hi All -
I need your help to resolve this. I have gone through some basic examples of xml and their conversion to xslt, but the one i have to convert is something quite specific.

The XML schema for the execution log
-------------------------------------

<?xml version="1.0" encoding="utf-16"?>

<xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<xsd:element name="ExecutionLog">

<xsd:complexType>

<xsd:sequence>

<xsd:element name="LogHeader">

<xsd:complexType>

<xsd:sequence>

<xsd:element maxOccurs="unbounded" name="LogEntry">

<xsd:complexType>

<xsd:attribute name="value" type="xsd:string" />

</xsd:complexType>

</xsd:element>

</xsd:sequence>

<xsd:attribute name="value" type="xsd:string" />

</xsd:complexType>

</xsd:element>

</xsd:sequence>

<xsd:attribute name="version" type="xsd:decimal" />

</xsd:complexType>

</xsd:element>

</xsd:schema>


Example of an execution Log
---------------------------
<ExecutionLog version="1.0">

<LogHeader value="Reset cumulative values">

<LogEntry value="Checking beginning of the year" />

<LogEntry value="The beginning of the year" />

</LogHeader>

<LogHeader value="Information Updates">

<LogEntry value="Checking if the rate of 2200 is proper." />

<LogEntry value="Because 100% increase requires 24 hours" />

<LogEntry value="The effective date time is 10.12.2008 10:00" />

</LogHeader>

</ExecutionLog>

Can some one help me write an XSLT for the xml example given above? I have gone through the basic xml template examples in which the values are specified with in the opening and the closing tags, but since here the values have been specified as attributes, i couldn't come across any similar examples as to how to crack it.

Please suggest, thanks in advance!
-Walkman...

Member Avatar for gravyboat

This should get you started:

<xsl:template match="ExecutionLog">
  <xsl:value-of select="./LogHeader/@value"/>
  <xsl:value-of select="./LogHeader/LogEntry/@value"/>

etc.

</xsl:template>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.