Re: Output from node traversal not processing correctly
Michael Ludwig <[email protected]> Wed, 17 Feb 2010 23:03:58 +0100
| Newsgroups | gmane.text.xml.xalan.java.user |
|---|---|
| Message-ID | <20100217220358.GE3060@wladimir> |
Tim Hibbs schrieb am 17.02.2010 um 10:52:39 (-0600):
> Personal Context:
> - New to XSL, Xalan. Have taken care to try all options I can think
> of before soliciting for assistance here. Don't fully understand
> Debugger outputs (below).
I'd consider reading a good introductory tutorial or even a book.
Recommended teachers include:
* Michael Kay
* Jeni Tennison
* Evan Lenz
You should be able to locate books and tutorials.
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <tFreightRateQuotation
> xmlns="http://www.fedex.com/schemas/freightRateQuotation">
Namespace declared and used!
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
No namepace declared :-(
> <xsl:template match="/">
> <html>
> <body>
> <xsl:apply-templates />
You need to put a suitable XPath here, else too much output.
> <xsl:template match="To">
> To: <xsl:value-of select="."/>
> <xsl:apply-templates/>
> </xsl:template>
Two items you absolutely want to learn about at the beginning:
* built-in template rules
* identity template (very common coding pattern)
> Logging information (from "Debugger Interface",
Don't worry about debugging yet.
Here's a working example:
C:\cygwin\tmp :: more /t2 tim.xsl
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:frq="http://www.fedex.com/schemas/freightRateQuotation"
exclude-result-prefixes="frq"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<html>
<body>
<div>
<xsl:apply-templates select="*/frq:CommonData/frq:To"/>
</div>
</body>
</html>
</xsl:template>
<xsl:template match="frq:To"> To: <xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet>
C:\cygwin\tmp :: xalan tim.xml tim.xsl
<html>
<body>
<div> To: John Customer</div>
</body>
</html>
Best,
--
Michael Ludwig