View Single Post
  #1 (permalink)  
Old August 13th, 2014, 06:25 PM
tatetiffany tatetiffany is offline
Registered User
Points: 22, Level: 1
Points: 22, Level: 1 Points: 22, Level: 1 Points: 22, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2014
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default XLST transform xml multiple query and display results in html table

I have an xlst that returns multiple results. I want to add headers at the top of the xml so it has something like: Display label Ci Type Environment Phbrsp-s3297 Node Production Phbrsp-s3235 node Production

at the moment the xlst is displaying the header for each returned result but i dont want it to be like that. I tested with the header for display name thats when it was displaying on the new line for each result. that is my current xslt:
the xlst query
Code:
<?xml version="1.0" ?>
 
<xsl:stylesheet version="1.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
 
<xsl:template match ="/" >
 
            <html>
 
              <head>
 
                        <title> title </title>
 
              </head>
 
              <body>
 
                        <xsl:apply-templates />
 
              </body>
 
            </html>
 
</xsl:template>
 
 
 
<xsl:template match="CMDBRelation" >
 
            <table width="400" border="1" >
 
                                                <tr>
 
<xsl:for-each select="To/CMDBObject/Properties" >
 
        <td> <xsl:value-of select="display_label" /> </td>      
        <td> <xsl:value-of select="root_class" /> </td>
 
 
 
</xsl:for-each>                                   
<xsl:for-each select="From/CMDBObject/Properties" >
 
                                    <td> <xsl:value-of select="resolver_group" /> </td>
 
                                    <td> <xsl:value-of select="supported_by" /> </td>
 
                                    <td> <xsl:value-of select="environment" /> </td>
 
                                    <td><th>  <xsl:value-of select="site_code" /> </th></td>
 
                                    <td> <xsl:value-of select="sla_classification" /> </td>
 
                                    <td> <xsl:value-of select="datacenter" /> </td>
 
 
 
 
 
</xsl:for-each>
 
                                    </tr>
 
            </table>
 
</xsl:template >
 
</xsl:stylesheet >
and the xml

Code:
<CMDBRelation>
        <identifier type="containment">8307958f5a00e7f735df5c197dcbab3e</identifier>
        <Properties />
        <From>
          <CMDBObject>
            <identifier type="infra_details">2bb729e0255d17ffd6fd2655a0339aa1</identifier>
            <Properties>
              <resolver_group type="STRING">Not Defined</resolver_group>
              <supported_by type="STRING" />
              <environment type="STRING">Production</environment>
              <site_code type="STRING">BRSP</site_code>
              <sla_classification type="STRING">Bronze</sla_classification>
              <datacenter type="STRING">Not Defined</datacenter>
            </Properties>
          </CMDBObject>
        </From>
        <To>
          <CMDBObject>
            <identifier type="node">93174788d73bc681d4e236d53ef447e3</identifier>
            <Properties>
              <root_class type="STRING">node</root_class>
              <display_label type="STRING">phbrsp-s3297</display_label>
            </Properties>
          </CMDBObject>
        </To>
      </CMDBRelation>|<CMDBRelation>
        <identifier type="containment">25fa93e9e5f2a34491c69b8f060362be</identifier>
        <Properties />
        <From>
          <CMDBObject>
            <identifier type="infra_details">69d01957564e4be3e1e825a6430ccea8</identifier>
            <Properties>
              <resolver_group type="STRING">Novartis:GL_APPS_XX:GL_EWS-APM-SUPPORT</resolver_group>
              <supported_by type="STRING" />
              <environment type="STRING">Production</environment>
              <site_code type="STRING">BRSP</site_code>
              <sla_classification type="STRING">Bronze</sla_classification>
              <datacenter type="STRING">Not Defined</datacenter>
            </Properties>
          </CMDBObject>
        </From>
        <To>
          <CMDBObject>
            <identifier type="node">4f1e38a3387715ef6548d555770eaa9b</identifier>
            <Properties>
              <root_class type="STRING">node</root_class>
              <display_label type="STRING">phbrsp-s3235</display_label>
            </Properties>
          </CMDBObject>
        </To>
      </CMDBRelation>|<CMDBRelation>
        <identifier type="containment">9261563a2722f9d157194e6ea3b041f9</identifier>
        <Properties />
        <From>
          <CMDBObject>
            <identifier type="infra_details">383c8681ef161e9e6f782f6e63780c3b</identifier>
            <Properties>
              <resolver_group type="STRING">Not Defined</resolver_group>
              <supported_by type="STRING" />
              <environment type="STRING">Production</environment>
              <site_code type="STRING">BRSP</site_code>
              <sla_classification type="STRING">Bronze</sla_classification>
              <datacenter type="STRING">Not Defined</datacenter>
            </Properties>
          </CMDBObject>
        </From>
        <To>
          <CMDBObject>
            <identifier type="node">5a785cd5bb2d0494a85ebf38b41d2af6</identifier>
            <Properties>
              <root_class type="STRING">node</root_class>
              <display_label type="STRING">brsptsm01</display_label>
            </Properties>
          </CMDBObject>
        </To>
      </CMDBRelation>