954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

XML to XSLT for XML with value in attribute

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...

walk_man
Newbie Poster
1 post since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

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>
gravyboat
Newbie Poster
14 posts since Jun 2008
Reputation Points: 10
Solved Threads: 2
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You