R
Rey
Howdy all.
Read and worked through the XSLT part of Castro's XML for the World Wide
web. Then tried to apply to a test case and get the following:
- no table is displayed, i.e. no header, no tbl frame
When I started this yesterday, I got 3 header displays but no table frame;
made a change then got the 3 ItemID numbers but all in a row w/no separation
and still no table frame.
Had tried using the apply-templates meth for the table data fields with
matching templates but no success. Then tried using value-of - still no
success.
Have validated the XML file using the w3schools page
(http://www.w3schools.com/dom/dom_validate.asp) - no errs.
Appreciate if you could provide suggestion/comments on what I'm doing wrong.
Looking at getting the XSLT for dummies book but also reading through the
XSLT transformation tutorial at w3.org
(http://www.w3.org/TR/1999/REC-xslt-19991116).
Some additional questions:
what's the difference between XSLT v 1.0 and 2.0.?
In the Catro book, she uses subspecies in the for-each select part to
display table rows while the w3schools approach (catalog/cd example) uses
catalog/cd. Guess both are correct, but does this mean that you need to
specify the path to the rows in order to display them in the table? Is there
a shortcut way of specifying a long path by using a variable similar to
SUBST in DOS?
Thank you in advance for your help,
Rey
XML and XSL files below
***************************
XML file:
<?xml-stylesheet type="text/xsl" href="MikeCertTest.xsl"?>
<Root TestName="Designing and Implementing Distributed Applications with
Microsoft Visual Basic 6.0"><Item ItemID="784199"
QuestionItemType="12"><ItemType><item
type="fusion"><question><validationmap><INPUT_Group1>RB_0</INPUT_Group1></va
lidationmap><options><labelquest><div>Why can an ActiveX DLL not be assigned
an Instancing property of SingleUse?</div><br/></labelquest><table><tr><td
valign="top"><input type="radio" name="INPUT_Group1" id="RB_0"
value="RB_0"/></td><td for="RB_0"><label> because it is an in-process
component</label></td></tr></table></options></question></item>
</ItemType><SectionDescription>Creating and Managing COM
Components</SectionDescription></Item><Item ItemID="784184"
QuestionItemType="12"><ItemType><item
type="fusion"><question><validationmap><INPUT_Group1>RB_0</INPUT_Group1></va
lidationmap><options><labelquest><div>Which object is the base object used
to create an ActiveX control?</div><br/></labelquest><table><tr><td
valign="top"><input type="radio" name="INPUT_Group1" id="RB_0"
value="RB_0"/></td><td for="RB_0"><label>
UserControl</label></td></tr></table></options></question></item>
</ItemType><SectionDescription>Creating and Managing COM
Components</SectionDescription></Item><Item ItemID="784152"
QuestionItemType="12"><ItemType><item
type="fusion"><question><validationmap><INPUT_Group1>RB_0</INPUT_Group1></va
lidationmap><options><labelquest><div>Why would you use the Friend keyword
when declaring a procedure within a class
module?</div><br/></labelquest><table><tr><td valign="top"><input
type="radio" name="INPUT_Group1" id="RB_0" value="RB_0"/></td><td
for="RB_0"><label> You want other classes within the component to use the
procedure, but not other client
applications.</label></td></tr></table></options></question></item>
</ItemType><SectionDescription>Creating and Managing COM
Components</SectionDescription></Item>
</Root>
**************
XSL file:
<?xml version="1.0"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- applied to root node of xml document -->
<xsl:template match="/">
<!-- output to html -->
<html>
<head>
<title>Test Output - Answers to Certification Exam Questions</title>
</head>
<body bgcolor="white">
<!-- is for non-breaking space -->
<!-- get/display test name -->
<p><b>Test Name: </b><xsl:value-of
select="Root/@testname"/></p>
<xsl:apply-templates
select="Root/Item"/>
</body>
</html>
</xsl:template>
<xsl:template match="Item">
<table width="100%" border="1" >
<tr><th>ItemID</th><th>Question</th><th>Answer</th><th>Section
Description</th></tr>
<!-- loop thru each Q & A -->
<xsl:for-each select="ItemType">
<tr>
<td><xsl:value-of
select="Item/@ItemID"/></td>
<td><xsl:value-of
select="div"/></td>
<td><xsl:value-of select="label"/></td>
<td><xsl:value-of
select="SectionDescription"/></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
<xsl:template match="Item"><b><xsl:value-of
select="Item[@ItemID]"/></b></xsl:template>
<xsl:template match="div"><xsl:value-of select="."/></xsl:template>
<xsl:template match="label"><xsl:value-of select="."/></xsl:template>
<xsl:template match="SectionDescription"><xsl:value-of
select="."/></xsl:template>
</xsl:stylesheet>
Read and worked through the XSLT part of Castro's XML for the World Wide
web. Then tried to apply to a test case and get the following:
- no table is displayed, i.e. no header, no tbl frame
When I started this yesterday, I got 3 header displays but no table frame;
made a change then got the 3 ItemID numbers but all in a row w/no separation
and still no table frame.
Had tried using the apply-templates meth for the table data fields with
matching templates but no success. Then tried using value-of - still no
success.
Have validated the XML file using the w3schools page
(http://www.w3schools.com/dom/dom_validate.asp) - no errs.
Appreciate if you could provide suggestion/comments on what I'm doing wrong.
Looking at getting the XSLT for dummies book but also reading through the
XSLT transformation tutorial at w3.org
(http://www.w3.org/TR/1999/REC-xslt-19991116).
Some additional questions:
what's the difference between XSLT v 1.0 and 2.0.?
In the Catro book, she uses subspecies in the for-each select part to
display table rows while the w3schools approach (catalog/cd example) uses
catalog/cd. Guess both are correct, but does this mean that you need to
specify the path to the rows in order to display them in the table? Is there
a shortcut way of specifying a long path by using a variable similar to
SUBST in DOS?
Thank you in advance for your help,
Rey
XML and XSL files below
***************************
XML file:
<?xml-stylesheet type="text/xsl" href="MikeCertTest.xsl"?>
<Root TestName="Designing and Implementing Distributed Applications with
Microsoft Visual Basic 6.0"><Item ItemID="784199"
QuestionItemType="12"><ItemType><item
type="fusion"><question><validationmap><INPUT_Group1>RB_0</INPUT_Group1></va
lidationmap><options><labelquest><div>Why can an ActiveX DLL not be assigned
an Instancing property of SingleUse?</div><br/></labelquest><table><tr><td
valign="top"><input type="radio" name="INPUT_Group1" id="RB_0"
value="RB_0"/></td><td for="RB_0"><label> because it is an in-process
component</label></td></tr></table></options></question></item>
</ItemType><SectionDescription>Creating and Managing COM
Components</SectionDescription></Item><Item ItemID="784184"
QuestionItemType="12"><ItemType><item
type="fusion"><question><validationmap><INPUT_Group1>RB_0</INPUT_Group1></va
lidationmap><options><labelquest><div>Which object is the base object used
to create an ActiveX control?</div><br/></labelquest><table><tr><td
valign="top"><input type="radio" name="INPUT_Group1" id="RB_0"
value="RB_0"/></td><td for="RB_0"><label>
UserControl</label></td></tr></table></options></question></item>
</ItemType><SectionDescription>Creating and Managing COM
Components</SectionDescription></Item><Item ItemID="784152"
QuestionItemType="12"><ItemType><item
type="fusion"><question><validationmap><INPUT_Group1>RB_0</INPUT_Group1></va
lidationmap><options><labelquest><div>Why would you use the Friend keyword
when declaring a procedure within a class
module?</div><br/></labelquest><table><tr><td valign="top"><input
type="radio" name="INPUT_Group1" id="RB_0" value="RB_0"/></td><td
for="RB_0"><label> You want other classes within the component to use the
procedure, but not other client
applications.</label></td></tr></table></options></question></item>
</ItemType><SectionDescription>Creating and Managing COM
Components</SectionDescription></Item>
</Root>
**************
XSL file:
<?xml version="1.0"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- applied to root node of xml document -->
<xsl:template match="/">
<!-- output to html -->
<html>
<head>
<title>Test Output - Answers to Certification Exam Questions</title>
</head>
<body bgcolor="white">
<!-- is for non-breaking space -->
<!-- get/display test name -->
<p><b>Test Name: </b><xsl:value-of
select="Root/@testname"/></p>
<xsl:apply-templates
select="Root/Item"/>
</body>
</html>
</xsl:template>
<xsl:template match="Item">
<table width="100%" border="1" >
<tr><th>ItemID</th><th>Question</th><th>Answer</th><th>Section
Description</th></tr>
<!-- loop thru each Q & A -->
<xsl:for-each select="ItemType">
<tr>
<td><xsl:value-of
select="Item/@ItemID"/></td>
<td><xsl:value-of
select="div"/></td>
<td><xsl:value-of select="label"/></td>
<td><xsl:value-of
select="SectionDescription"/></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
<xsl:template match="Item"><b><xsl:value-of
select="Item[@ItemID]"/></b></xsl:template>
<xsl:template match="div"><xsl:value-of select="."/></xsl:template>
<xsl:template match="label"><xsl:value-of select="."/></xsl:template>
<xsl:template match="SectionDescription"><xsl:value-of
select="."/></xsl:template>
</xsl:stylesheet>