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

how to extract xs:element name and xs:documentation from XSD using xslt and put data

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 for all elements names (4 example ) 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"?>
Prc 1.0, 19.11.2010Some descriptionPersondocumentation for zzzzdocumentation for wwwww

XML

HfC8PH1LzUIzougK8qwFm5lX5KgTVzgso9xVVPnVeBOZawdEqT8zOXx1g7U9tbBMtext2011-03-24T11:27:36value of zzzvalue of www

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?

tequila1
Newbie Poster
1 post since May 2011
Reputation Points: 10
Solved Threads: 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>
xml_looser
Junior Poster
179 posts since Apr 2009
Reputation Points: 16
Solved Threads: 21
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: