Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 30th, 2015, 02:45 PM
Registered User
 
Join Date: Mar 2015
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Cool XSLT 001 (not 101)

I'm on my third XSLT conversion project. This time, I can't make any progress at all! I've stripped my files down to bare minimums...

First, my input XML to be parsed (myFile.xml):
Code:
<?xml version="1.0" encoding="UTF-8"?>
<TimeSeries xmlns="http://www.wldelft.nl/fews/PI"    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://fews.wldelft.nl/schemas/version1.0/pi-schemas/pi_timeseries.xsd" version="1.4">
    <timeZone>0.0</timeZone>
	<tzName>Universal Time</tzName>
</TimeSeries>
Now, my XSL stylesheet (PIXML2SHEF.xsl):
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet extension-element-prefixes="ex" xmlns:ex="http://exslt.org/dates-and-times" xmlns:ns1="http://fews.wldelft.nl/schemas/version1.0/pi-schemas/pi_timeseries.xsd" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/TimeSeries">
<xsl:variable select="timeZone" name="tz"/>
<xsl:value-of select="$tz"/>
<xsl:text>_________</xsl:text>
</xsl:template>
</xsl:stylesheet>
For reasons I cannot understand, The underscores do not print to the screen. Rather, what happens is the 0.0 and the "Universal Time" strings get printed to the screen, as if I had no XSL stylesheet at all. If I replace
Code:
match="/timeSeries"
with
Code:
match="/"
then I get the underscores to print out, but the $tz variable is always empty (expecting 0.0). I cannot figure out what I am doing wrong. My command is:
Code:
cat myFile.xml | xsltproc -v PIXML2SHEF.xsl -
Any ideas?
Mark
 
Old March 30th, 2015, 03:51 PM
Registered User
 
Join Date: Feb 2015
Posts: 3
Thanks: 0
Thanked 1 Time in 1 Post
Default

Your XML is in namespace "http://www.wldelft.nl/fews/PI" but your XSLT does not take it into account.
 
Old March 30th, 2015, 04:15 PM
Registered User
 
Join Date: Mar 2015
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Default

So, how do I take that into account? I've tried several things, but none of them have changed the results.
 
Old March 30th, 2015, 04:22 PM
Registered User
 
Join Date: Feb 2015
Posts: 3
Thanks: 0
Thanked 1 Time in 1 Post
Default

For example,
Code:
<xsl:stylesheet extension-element-prefixes="ex" xmlns:ex="http://exslt.org/dates-and-times" xmlns:ns1="http://fews.wldelft.nl/schemas/version1.0/pi-schemas/pi_timeseries.xsd" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:pi="http://www.wldelft.nl/fews/PI">
<xsl:template match="/pi:TimeSeries">
<xsl:variable select="pi:timeZone" name="tz"/>
...
The Following User Says Thank You to CitySeven For This Useful Post:
fenbers (March 30th, 2015)





Similar Threads
Thread Thread Starter Forum Replies Last Post
error 101 in asp.net?? harshil.sh C# 4.0 aka C# 2010 General Discussion 1 June 5th, 2011 05:01 PM
Page 101 Kim_arg_js BOOK: Beginning JavaScript 4th Edition 0 July 6th, 2010 02:04 PM
Get files with 001, 002, 003 aso. names.. Rafter Visual Basic 2005 Basics 1 March 15th, 2007 06:20 AM
paging 001+001=002 <> 2 gilgalbiblewheel Classic ASP Databases 1 February 15th, 2005 05:34 AM
Chapter 3, page 101. File modes. venquessa BOOK Beginning Linux Programming, 3rd Edition 2 December 3rd, 2004 01:30 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.