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 November 19th, 2007, 11:19 AM
Authorized User
 
Join Date: May 2007
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default help with xslt transformation

Hi. everyone
I am new to xslt and Xforms technologies. I am trying to write a very simple xslt stylesheet to transform a very simple xml doc into Xforms doc. (Hello world example)
here are my xml doc and xslt stylesheet could plz tell me what wrong
with my stylesheet. Remark: X-smiles is used as web browser.
the page is called as: http://localhost:8080/mydoc.xml
both xml do and xslt stylesheet in the same directory

many thanks in advance
<?xml version='1.0'?>
<?xml-stylesheet type="text/xsl" stylesheet01.xslt"?>
 <data>
   <Name> Hello World </Name>
 </data>

and here is XSLT
<?xml version='1.0'?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events"
 xmlns:xforms="http://www.w3.org/2002/xforms/cr" xmlns:xmml="http://www.xmml.com" >
<xsl:output method="xhtml" indent="yes"
 doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
 doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />


<xsl:template match="/">

<html>
<head>
    <title>Title comes here </title>
     <xforms:model >
        <xforms:submission action="" method="post" id="s"/>

        <xforms:instance>
          <xsl:apply-templates select="data" />
         </xforms:instance>
          </xforms:model >
</head>
<body>
  <p> Hi.
  <xforms:output ref="data/name"/>
  </p>
</body>
</html>
</xsl:template>

<xsl:template match="data/name">
  <xsl:copy>
    <xsl:copy-of select="data/name"/>
  </xsl:copy>
  </xsl:template>
  </xsl:stylesheet>
 
Old November 19th, 2007, 11:43 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Well one thing is that your processing instruction
Code:
<?xml-stylesheet type="text/xsl" stylesheet01.xslt"?>
should be
Code:
<?xml-stylesheet type="text/xsl" href="stylesheet01.xslt"?>
but you haven't said what the error or problem is, what's happening and how does this differ from what you are expecting?

(Does x-smiles support XSLT version 2.0?)

--

Joe (Microsoft MVP - XML)
 
Old November 19th, 2007, 12:03 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Your stylesheet runs OK and produces output. So what makes you think there is anything wrong with it? (Give us a clue, we are human)

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old November 19th, 2007, 12:47 PM
Authorized User
 
Join Date: May 2007
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

this is waht X-smiles display:
http://localhost:8080/mydoc.xml
nulljava.net.MalformedURLException
    at java.net.URL.<init>(Unknown Source)
    at java.net.URL.<init>(Unknown Source)
    at fi.hut.tml.xsmiles.XSmilesXMLDocument.findXSL(XSmi lesXMLDocument.java:426)
    at fi.hut.tml.xsmiles.XSmilesXMLDocument.transformDoc ument(XSmilesXMLDocument.java:175)
    at fi.hut.tml.xsmiles.XSmilesXMLDocument.retrieveDocu ment(XSmilesXMLDocument.java:163)
    at fi.hut.tml.xsmiles.content.xml.XMLContentHandler.f etchParseAndTransformDocument(XMLContentHandler.ja va:171)
    at fi.hut.tml.xsmiles.content.xml.XMLContentHandler.f etch(XMLContentHandler.java:116)
    at fi.hut.tml.xsmiles.content.xml.XMLContentHandler.p refetch(XMLContentHandler.java:46)
    at fi.hut.tml.xsmiles.content.xml.XMLContentHandler.p lay(XMLContentHandler.java:60)
    at fi.hut.tml.xsmiles.Browser$HandlerThread.run(Brows er.java:765)
    at java.lang.Thread.run(Unknown Source)

 
Old November 19th, 2007, 01:26 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Presumably xsmiles is objecting to

<xforms:submission action="" method="post" id="s"></xforms:submission>

Since action="" is precisely what your stylesheet asks to be output, I don't quite see how you classify this as an XSLT problem?

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old November 19th, 2007, 01:45 PM
Authorized User
 
Join Date: May 2007
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi. even if we eliminate the
  <xforms:submission action="" method="post" id="s"></xforms:submission>
we still get the same problem.
any other clue?
plz help
cheers


 
Old November 19th, 2007, 01:51 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

If the output of your transformation isn't valid XForms, and you don't understand why, then you need to ask on an XForms forum. The fact that your XForms document was generated using XSLT is completely irrelevant to your problem.

Before starting to write a program in XSLT or any other language, it's always a good idea to know what output you want it to produce. We can't really help you with that.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
help on xslt transformation li72 XSLT 2 March 4th, 2008 10:14 AM
Help on XSLT transformation li72 XSLT 2 February 22nd, 2008 12:33 PM
XSLT transformation using JDK 1.5.0 kgoldvas XSLT 4 October 30th, 2007 02:06 PM
XSLT transformation yengzhai XSLT 1 April 21st, 2005 05:51 AM
XSLT transformation causes ^M reddygaru XSLT 2 December 16th, 2003 10:41 AM





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