XSL: how to properly reference to xml field?
-
I'm looking for a way to properly set
xsl:match="..."
orxsl:value-of select="..."
My files are: test.xsl<?xml version="1.0" encoding="Windows-1250"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<!--<xsl:template match="DocumentContent/section[@name]">-->
<html>
<head>
<!-- <link rel="stylesheet" href="zastyles.css"/> -->
</head>
<body>
<h2>SingleRow1</h2>
<table border="1px" bgcolor="yellow">
<tr>
<td><xsl:value-of select="DocumentContent/section['SingleRow1']/row/FieldA"/>
</td>
<td><xsl:value-of select="DocumentContent/section['SingleRow1']/row/FieldB"/>
</td>
<td><xsl:value-of select="DocumentContent/section['SingleRow1']/row/FieldC"/>
</td>
<td><xsl:value-of select="DocumentContent/section['SingleRow1']/row/FieldD"/>
</td>
</tr>
</table>
<br/>
<h2>SingleRow2</h2>
<table border="1px" bgcolor="yellow">
<tr>
<td><xsl:value-of select="DocumentContent/section['SingleRow2']/row/FieldA"/>
</td>
<td><xsl:value-of select="DocumentContent/section['SingleRow2']/row/FieldB"/>
</td>
<td><xsl:value-of select="DocumentContent/section['SingleRow2']/row/FieldC"/>
</td>
<td><xsl:value-of select="DocumentContent/section['SingleRow2']/row/FieldD"/>
</td>
</tr>
</table>
<h2>MulitRow1</h2>
<table border="1px" bgcolor="lightgreen">
<xsl:for-each select="DocumentContent/section['MultiRow1']/row">
<tr>
<td><xsl:value -
I'm looking for a way to properly set
xsl:match="..."
orxsl:value-of select="..."
My files are: test.xsl<?xml version="1.0" encoding="Windows-1250"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<!--<xsl:template match="DocumentContent/section[@name]">-->
<html>
<head>
<!-- <link rel="stylesheet" href="zastyles.css"/> -->
</head>
<body>
<h2>SingleRow1</h2>
<table border="1px" bgcolor="yellow">
<tr>
<td><xsl:value-of select="DocumentContent/section['SingleRow1']/row/FieldA"/>
</td>
<td><xsl:value-of select="DocumentContent/section['SingleRow1']/row/FieldB"/>
</td>
<td><xsl:value-of select="DocumentContent/section['SingleRow1']/row/FieldC"/>
</td>
<td><xsl:value-of select="DocumentContent/section['SingleRow1']/row/FieldD"/>
</td>
</tr>
</table>
<br/>
<h2>SingleRow2</h2>
<table border="1px" bgcolor="yellow">
<tr>
<td><xsl:value-of select="DocumentContent/section['SingleRow2']/row/FieldA"/>
</td>
<td><xsl:value-of select="DocumentContent/section['SingleRow2']/row/FieldB"/>
</td>
<td><xsl:value-of select="DocumentContent/section['SingleRow2']/row/FieldC"/>
</td>
<td><xsl:value-of select="DocumentContent/section['SingleRow2']/row/FieldD"/>
</td>
</tr>
</table>
<h2>MulitRow1</h2>
<table border="1px" bgcolor="lightgreen">
<xsl:for-each select="DocumentContent/section['MultiRow1']/row">
<tr>
<td><xsl:valueYou can't just use the value of an attribute on the node as an indexer into the collection of nodes. You need to specify the attribute name and a comparison operator:
DocumentContent/section[@name = 'SingleRow1']/row/FieldA
Your current XSL is matching every<section>
node, which is why you're getting two blank lines at the start of your<xsl:for-each>
block - one for "SingleRow1", and one for "SingleRow2".<?xml version="1.0" encoding="Windows-1250"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<!--<xsl:template match="DocumentContent/section[@name]">-->
<html>
<head>
<!-- <link rel="stylesheet" href="zastyles.css"/> -->
</head>
<body>
<h2>SingleRow1</h2>
<table border="1px" bgcolor="yellow">
<tr>
<td><xsl:value-of select="DocumentContent/section[@name = 'SingleRow1']/row/FieldA"/>
</td>
<td><xsl:value-of select="DocumentContent/section[@name = 'SingleRow1']/row/FieldB"/>
</td>
<td><xsl:value-of select="DocumentContent/section[@name = 'SingleRow1']/row/FieldC"/>
</td>
<td><xsl:value-of select="DocumentContent/section[@name = 'SingleRow1']/row/FieldD"/>
</td>
</tr>
</table>
<br/>
<h2>SingleRow2</h2>
<table border="1px" bgcolor="yellow">
<tr>
<td><xsl:value-of select="DocumentContent/section[@name = 'SingleRow2']/row/FieldA"/>
</td>
<td><xsl:value-of select="DocumentContent/section[@name = 'SingleRow2']/row/FieldB"/>
</td>
<td><xsl:value-of select="DocumentContent/section[@name = 'SingleRow2']/row/FieldC"/>
</td>
<td><xsl:value-of select="DocumentContent/section[@name -
You can't just use the value of an attribute on the node as an indexer into the collection of nodes. You need to specify the attribute name and a comparison operator:
DocumentContent/section[@name = 'SingleRow1']/row/FieldA
Your current XSL is matching every<section>
node, which is why you're getting two blank lines at the start of your<xsl:for-each>
block - one for "SingleRow1", and one for "SingleRow2".<?xml version="1.0" encoding="Windows-1250"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<!--<xsl:template match="DocumentContent/section[@name]">-->
<html>
<head>
<!-- <link rel="stylesheet" href="zastyles.css"/> -->
</head>
<body>
<h2>SingleRow1</h2>
<table border="1px" bgcolor="yellow">
<tr>
<td><xsl:value-of select="DocumentContent/section[@name = 'SingleRow1']/row/FieldA"/>
</td>
<td><xsl:value-of select="DocumentContent/section[@name = 'SingleRow1']/row/FieldB"/>
</td>
<td><xsl:value-of select="DocumentContent/section[@name = 'SingleRow1']/row/FieldC"/>
</td>
<td><xsl:value-of select="DocumentContent/section[@name = 'SingleRow1']/row/FieldD"/>
</td>
</tr>
</table>
<br/>
<h2>SingleRow2</h2>
<table border="1px" bgcolor="yellow">
<tr>
<td><xsl:value-of select="DocumentContent/section[@name = 'SingleRow2']/row/FieldA"/>
</td>
<td><xsl:value-of select="DocumentContent/section[@name = 'SingleRow2']/row/FieldB"/>
</td>
<td><xsl:value-of select="DocumentContent/section[@name = 'SingleRow2']/row/FieldC"/>
</td>
<td><xsl:value-of select="DocumentContent/section[@nameThank you, Richard so much ;) Last few days i was struggle with it
section[@thankyou='thank you']