0

I have a big problem and i'm not even sure if solution exists for my problem...
So the problem is:
I have a xsd file, and I need to create xslt which will create html table
with 2 columns: the first column is <xs:documentation> for all elements names (4 example <xs:element name="xxxxx">) from my xsd file, and the second column is the value of that the same element name="xxxxx" but the value must be extract from xml file.
XSD
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:igt="http://www.yxz.com/global" xmlns:bgt="http://www.yxz.com/Prc" xmlns:xdb="http://xmlns.oracle.com/xdb" targetNamespace="http://www.yxz.com/Prc" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.0">
<xs:import namespace="http://www.yxz.com/global" schemaLocation="global.xsd"/>
<xs:annotation>
<xs:appinfo>Prc 1.0, 19.11.2010</xs:appinfo>
<xs:documentation>Some description</xs:documentation>
</xs:annotation>
<xs:complexType name="TypePerson">
<xs:annotation>
<xs:documentation>Person</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="zzzzz" type="igt:String35Type" minOccurs="0">
<xs:annotation>
<xs:documentation>documentation for zzzz</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="wwwww" type="igt:String35Type" minOccurs="0">
<xs:annotation>
<xs:documentation>documentation for wwwww</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>

XML

<ns2:globalResponse xmlns:ns2="http://www.yxz.com/PrcWs" xmlns="http://www.yxz.com/global" xmlns:ns3="http://www.yxz.com/Prc">
<ns2:Header>
<JobId>HfC8PH1LzUIzougK8qwFm5lX5KgTVzgs</JobId>
<MsgId>o9xVVPnVeBOZawdEqT8zOXx1g7U9tbBM</MsgId>
<Operation Id="IO001">text</Operation>
<Status Id="OK"/>
<SysDate>2011-03-24T11:27:36</SysDate>
</ns2:Header>
<ns2:Body>
<ns2:ViewResponse>
<ns3:ListPerson Size="1">
<ns3:Person>
<ns3:zzzzz>value of zzz</ns3:zzzzz>
<ns3:wwwww>value of www</ns3:wwwww>
</ns3:Person>
</ns3:ListPerson>
</ns2:ViewResponse>
</ns2:Body>
</ns2:globalResponse>

And i would like the xslt which gives html table

||xsd element's documentation||value of element name in xml file||
----------------------------------------------------------------
||documentation for zzzz || value of zzz||

Is this even possible, and how?

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by xml_looser
0
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns2="http://www.yxz.com/PrcWs" xmlns:ns3="http://www.yxz.com/Prc" xmlns:a="http://www.yxz.com/global">
	<xsl:output indent="yes" method="html"/>
	<xsl:template match="/">
		<html>
			<style type="text/css">table{
		border: solid black 2px;
		margin: 20 px;
		}
		th,td{
		border: solid black 2px;
		}</style>
			<body>
				<xsl:apply-templates select="ns2:globalResponse"/>
			</body>
		</html>
	</xsl:template>
	<xsl:template match="ns2:globalResponse">
		<xsl:apply-templates select="ns2:Header"/>
		<xsl:apply-templates select="ns2:Body"/>
	</xsl:template>
	<xsl:template match="ns2:Header">
		<h1>
			<xsl:value-of select="a:Operation"/>
		</h1>
	</xsl:template>
	<xsl:template match="ns2:Body">
		<table>
			<tr>
				<th>ns3:zzzzz</th>
				<th>ns3:wwwww</th>
			</tr>
			<xsl:apply-templates select="ns2:ViewResponse/ns3:ListPerson"/>
		</table>
	</xsl:template>
	<xsl:template match="ns3:ListPerson">
		<tr>
			<xsl:apply-templates select="ns3:Person"/>
		</tr>
	</xsl:template>
	<xsl:template match="ns3:Person">
		<td>
			<xsl:value-of select="ns3:zzzzz"/>
		</td>
		<td>
			<xsl:value-of select="ns3:wwwww"/>
		</td>
	</xsl:template>
</xsl:stylesheet>

result

<html xmlns:ns3="http://www.yxz.com/Prc" xmlns:a="http://www.yxz.com/global" xmlns:ns2="http://www.yxz.com/PrcWs">
  <style type="text/css">table{
		border: solid black 2px;
		margin: 20 px;
		}
		th,td{
		border: solid black 2px;
		}
  </style>
  <body>
    <h1>text</h1>
    <table>
      <tr>
        <th>ns3:zzzzz</th>
        <th>ns3:wwwww</th>
      </tr>
      <tr>
        <td>value of zzz</td>
        <td>value of www</td>
      </tr>
    </table>
  </body>
</html>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.