Hi All,
I have an xml file like

<?xml version="1.0" encoding="UTF-8" ?> 
<?xml-stylesheet type="text/xsl" href="InProcess1.xsl"?>
 <Rowsets DateCreated="2011-02-14T12:24:00" EndDate="2011-02-14T12:24:00" StartDate="2011-02-14T11:24:00" Version="12.0.2 Build(88)">
 <Rowset>
 <Columns>
  <Column Description="BatchNumber" MaxRange="1" MinRange="0" Name="BatchNumber" SQLDataType="12" SourceColumn="BatchNumber" /> 
  <Column Description="VersionCode" MaxRange="1" MinRange="0" Name="VersionCode" SQLDataType="3" SourceColumn="VersionCode" /> 
  <Column Description="MaterialType" MaxRange="1" MinRange="0" Name="MaterialType" SQLDataType="12" SourceColumn="MaterialType" /> 
  <Column Description="LotNumber" MaxRange="1" MinRange="0" Name="LotNumber" SQLDataType="4" SourceColumn="LotNumber" /> 
  <Column Description="RRComplete" MaxRange="1" MinRange="0" Name="RRComplete" SQLDataType="-6" SourceColumn="RRComplete" /> 
  <Column Description="ReviewerName" MaxRange="1" MinRange="0" Name="ReviewerName" SQLDataType="12" SourceColumn="ReviewerName" /> 
  </Columns>
 <Row>
  <BatchNumber>A12345</BatchNumber> 
  <VersionCode>1</VersionCode> 
  <MaterialType>Raw</MaterialType> 
  <LotNumber>12345</LotNumber> 
  <RRComplete>0</RRComplete> 
  <ReviewerName>ankit</ReviewerName> 
  </Row>
  </Rowset>
  </Rowsets>

and i applied xslt

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:java="http://xml.apache.org/xslt/java" exclude-result-prefixes="java">
<xsl:template match="/">
    <xsl:apply-templates select="Rowsets/Rowset"/>
</xsl:template>
<xsl:template match="Rowsets/Rowset">
<html>
<head>
<title> In Process Batch Details </title>
<LINK href="Content.css" rel="stylesheet" type="text/css"/>
</head>
<body>>
<table cellpadding="0" cellspacing="0" width="100%" height="100%" border="2" class="ContentHeaderSection" >
<tr>
<td>
	<table width="60%" height="60%" class="Content" cellspacing="1" cellpadding="4" bordercolor="#FFFFFF" border="2" align="center" style="margin-top:120px;">
		<tr>
			<th colspan="2" class="ContentSubTitleBar ContentSubTitle">In Process Batch Details
			</th>
			
		</tr>
		<tr>
			<td>
				<xsl:for-each select="Columns/Column">
				<tr>
					
					<td><xsl:value-of select="@Name"/></td>
					<xsl:variable name="BatchDetails" select="@Name" />
					[B]<td><xsl:value-of select="../../Row/$BatchDetails"/></td>[/B]				</tr>
				</xsl:for-each>

			</td>
		</tr>
	</table>
</td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

My requriement is like i should loop through the columns and get the column name and to that column name mapping with rows i need to get the value of that row need to be displayed.
<xsl:value-of select="../../Row/$BatchDetails"/> in the place of this if i give
<xsl:value-of select="../../Row/BatchNumber"/>
i am getting the output as
BatchNumber A12345
VersionCode A12345
MaterialType A12345
LotNumber A12345
RRComplete A12345
ReviewerName A12345
but if i give this <xsl:value-of select="../../Row/$BatchDetails"/>i am getting an error like NodeTest expected here. ../../Row/-->$<--BatchDetails

Please help me if any one knows the xpath need to be given.

Thanks and regards,
Sireesha

use not for-each
xsl is not a programming language
think in xslt
use style tag for css

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" method="html"/>
	<xsl:template match="/">
		<html>
		<style>
		table.ContentHeaderSection {
		cellpadding :0;
		cellspacing :0;
		width :100%; 
		height :100%;
		border :2px solid black;
		text-align :center;
		}
		table.Content {
		width :60%;
		height :60%;
		cellspacing :1;
		cellpadding :4;
		background-color:#FFFF00;
		border :2px solid black;
		text-align :center;
		margin-top:120px;
		}
		</style>
			<body>
				<xsl:apply-templates select="Rowsets"/>
			</body>
		</html>
	</xsl:template>
	<xsl:template match="Rowsets">
		<xsl:apply-templates select="Rowset"/>
	</xsl:template>
	<xsl:template match="Rowset">
		<xsl:apply-templates select="Columns"/>
	</xsl:template>
	<xsl:template match="Columns">
		<table  class="ContentHeaderSection">
			<tr>
				<td>
					<table class="Content" >
						<tr>
							<th colspan="2" class="ContentSubTitleBar ContentSubTitle">In Process Batch Details</th>
						</tr>
						<tr>
							<td>
								<xsl:apply-templates select="Column"/>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</xsl:template>
	<xsl:template match="Column">
		<tr>
			<td>
				<xsl:value-of select="@Name"/>
			</td>
			<xsl:variable name="BatchDetails" select="@Name"/>
			<td>
				<xsl:value-of select="../../Row/*[local-name()=$BatchDetails]"/>
			</td>
		</tr>
	</xsl:template>
</xsl:stylesheet>

Hi,
Thanks for the explanation.
could you please explain me why cant we directly use this <xsl:value-of select="../../Row/$BatchDetails"/> instead <xsl:value-of select="../../Row/*[local-name()=$BatchDetails]"/>.
I know that local-name() gives the name excluding namespace.My doubt is like $BatchDetails should directly map to the column name right???
Regards,
Sireesha

with namespace
xml to test

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="InProcess1.xsl"?>
<ns:Rowsets DateCreated="2011-02-14T12:24:00" EndDate="2011-02-14T12:24:00" StartDate="2011-02-14T11:24:00" Version="12.0.2 Build(88)" xmlns:ns="http://www.namespace1/v1/">
	<ns:Rowset>
		<ns:Columns>
			<ns:Column Description="BatchNumber" MaxRange="1" MinRange="0" Name="BatchNumber" SQLDataType="12" SourceColumn="BatchNumber"/>
			<ns:Column Description="VersionCode" MaxRange="1" MinRange="0" Name="VersionCode" SQLDataType="3" SourceColumn="VersionCode"/>
			<ns:Column Description="MaterialType" MaxRange="1" MinRange="0" Name="MaterialType" SQLDataType="12" SourceColumn="MaterialType"/>
			<ns:Column Description="LotNumber" MaxRange="1" MinRange="0" Name="LotNumber" SQLDataType="4" SourceColumn="LotNumber"/>
			<ns:Column Description="RRComplete" MaxRange="1" MinRange="0" Name="RRComplete" SQLDataType="-6" SourceColumn="RRComplete"/>
			<ns:Column Description="ReviewerName" MaxRange="1" MinRange="0" Name="ReviewerName" SQLDataType="12" SourceColumn="ReviewerName"/>
		</ns:Columns>
		<ns:Row>
			<ns:BatchNumber>A12345</ns:BatchNumber>
			<ns:VersionCode>1</ns:VersionCode>
			<ns:MaterialType>Raw</ns:MaterialType>
			<ns:LotNumber>12345</ns:LotNumber>
			<ns:RRComplete>0</ns:RRComplete>
			<ns:ReviewerName>ankit</ns:ReviewerName>
		</ns:Row>
	</ns:Rowset>
</ns:Rowsets>
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  xmlns:ns="http://www.namespace1/v1/">
<xsl:output indent="yes" method="html"/>
	<xsl:template match="/">
		<html>
		<style>
		table.ContentHeaderSection {
		cellpadding :0;
		cellspacing :0;
		width :100%; 
		height :100%;
		border :2px solid black;
		text-align :center;
		}
		table.Content {
		width :60%;
		height :60%;
		cellspacing :1;
		cellpadding :4;
		background-color:#FFFF00;
		border :2px solid black;
		text-align :center;
		margin-top:120px;
		}
		</style>
			<body>
				<xsl:apply-templates select="ns:Rowsets"/>
			</body>
		</html>
	</xsl:template>


	<xsl:template match="ns:Rowsets">
	
		<xsl:apply-templates select="ns:Rowset"/>
	</xsl:template>
	<xsl:template match="ns:Rowset">
	
		<xsl:apply-templates select="ns:Columns"/>
	</xsl:template>
	<xsl:template match="ns:Columns">
		<table  class="ContentHeaderSection">
			<tr>
				<td>
					<table class="Content" >
						<tr>
							<th colspan="2" class="ContentSubTitleBar ContentSubTitle">In Process Batch Details</th>
						</tr>
						<tr>
							<td>
								<xsl:apply-templates select="ns:Column"/>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</xsl:template>
	<xsl:template match="ns:Column">
		<tr>
			<td>
				<xsl:value-of select="@Name"/>
			</td>
			<xsl:variable name="BatchDetails" select="@Name"/>
			<td>
				<xsl:value-of select="concat($BatchDetails,'  ',../../ns:Row/*[local-name(.)=$BatchDetails])"/>
			</td>
		</tr>
	</xsl:template>
</xsl:stylesheet>

in @Name is no namespace

xsl predicate means [[local-name(.)=$BatchDetails]] is equale porgramming language if stuctur ($BatchDetails is a string not a node)
if local-name = $BatchDetails then select
$BatchDetails is a string not a node
result

<html xmlns:ns="http://www.namespace1/v1/">
  <style>
		table.ContentHeaderSection {
		cellpadding :0;
		cellspacing :0;
		width :100%; 
		height :100%;
		border :2px solid black;
		text-align :center;
		}
		table.Content {
		width :60%;
		height :60%;
		cellspacing :1;
		cellpadding :4;
		background-color:#FFFF00;
		border :2px solid black;
		text-align :center;
		margin-top:120px;
		}
		
  </style>
  <body>
    <table class="ContentHeaderSection">
      <tr>
        <td>
          <table class="Content">
            <tr>
              <th colspan="2" class="ContentSubTitleBar ContentSubTitle">In Process Batch Details</th>
            </tr>
            <tr>
              <td>
                <tr>
                  <td>BatchNumber</td>
                  <td>BatchNumber  A12345</td>
                </tr>
                <tr>
                  <td>VersionCode</td>
                  <td>VersionCode  1</td>
                </tr>
                <tr>
                  <td>MaterialType</td>
                  <td>MaterialType  Raw</td>
                </tr>
                <tr>
                  <td>LotNumber</td>
                  <td>LotNumber  12345</td>
                </tr>
                <tr>
                  <td>RRComplete</td>
                  <td>RRComplete  0</td>
                </tr>
                <tr>
                  <td>ReviewerName</td>
                  <td>ReviewerName  ankit</td>
                </tr>
              </td>
            </tr>
          </table>
        </td>
      </tr>
    </table>
  </body>
</html>

Hi,
Thanks a lot for the clarification . :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.