I am trying to navigate through an XML and create an HTML file using XSLT.
This is my sample:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:monitor>
<ns0:messages>
<ns0:message>
<ns0:surrogate_key>R2DYSJ</ns0:surrogate_key>
<ns0:isFailed>false</ns0:isFailed>
<ns0:rollovers>
<ns0:rollover>
<ns0:conversation_id>Rollover.53789980697.18112016110321.48027</ns0:conversation_id>
<ns0:part_id>5378998069748027</ns0:part_id>
<ns0:transaction_type>INITIATE_OUT</ns0:transaction_type>
<ns0:transaction_status>IRR_ACCEPTED_BY_GATEWAY</ns0:transaction_status>
<ns0:transferring_usi>123213</ns0:transferring_usi>
<ns0:receiving_usi>123213</ns0:receiving_usi>
<ns0:mmbr_family_name>LG</ns0:mmbr_family_name>
<ns0:policy_number>1005905885</ns0:policy_number>
<ns0:isFailed>false</ns0:isFailed>
</ns0:rollover>
</ns0:rollovers>
</ns0:message>
<ns0:message>
<ns0:surrogate_key>R2DYTX</ns0:surrogate_key>
<ns0:isFailed>false</ns0:isFailed>
<ns0:rollovers>
<ns0:rollover>
<ns0:conversation_id>Rollover.53789980697.18112016110321.48027.ANZ</ns0:conversation_id>
<ns0:part_id>5378998069748027</ns0:part_id>
<ns0:transaction_type>INITIATE_IN</ns0:transaction_type>
<ns0:transaction_status>POLICY_DETAILS_NOT_FOUND</ns0:transaction_status>
<ns0:transferring_usi>123213</ns0:transferring_usi>
<ns0:receiving_usi>123213</ns0:receiving_usi>
<ns0:mmbr_family_name>LG</ns0:mmbr_family_name>
<ns0:isFailed>false</ns0:isFailed>
</ns0:rollover>
</ns0:rollovers>
</ns0:message>
</ns0:messages>
</ns0:monitor>
My XSLT looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1"></meta>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" ></link>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2>Rollovers Monitor</h2>
<p><strong>Note:</strong> This dashboard show data for only the last 3 days.</p>
<div class="panel-group" id="accordion">
<xsl:for-each select="//monitor/messages/message">
<xsl:choose>
<xsl:when test="isFailed = 'true'">
<xsl:element name="div">
<xsl:attribute name="class">
panel panel-danger
</xsl:attribute>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="div">
<xsl:attribute name="class">
panel panel-default
</xsl:attribute>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
<div class="panel-heading">
<h4 class="panel-title"><a data-toggle="collapse" data-parent="#accordion" href="#{surrogate_key}">Surrogate Key {surrogate_key}</a></h4>
</div>
and does more things after that. The result of this goes all the way to <div class="panel-group" id="accordion">
which essentially means I am hitting the xpath expression correctly.
Any ideas? Thanks