[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

XML to WML translation

  • From: Ben Sifuentes <bsifuentes@c...>
  • To: xml-dev@l...
  • Date: Tue, 05 Dec 2000 12:03:28 -0500

xml to wml
Can some explain to me why this doesn't work?

Currently, I'm using the JAXP release 2 and James Clark XT

I have the following coded:

XML
---

<name>
    <first>Ben</first>
    <last>Sifuentes</last>
</name>


XSL
---

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="wml"
 indent="yes"
 media-type="text/vnd.wap.xml"
 omit-xml-declaration="no"
 doctype-public="-//WAPFORUM//DTD WML 1.1//EN"
 doctype-system="http://www.wapforum.com/DTD/wml_1.1.xml"
/>
<xsl:template match="/">
<wml>
   <card id="main1" title="main card">
      <onevent type="ontimer">
	<go href="http://localhost:8080/jsp/mainmenu.jsp"/>
      </onevent>
      <timer value="60"/>
      <do type="accept" label="next">
	<go href="http://localhost:8080/jsp/mainmenu.jsp"/>
      </do>
      <do type="prev">
	<noop/>
      </do>
      <p>Welcome <xsl:value-of select="/name/first"/>
      <xsl:text> </xsl:text>
      <xsl:value-of select="/name/last"/> to AirBank!</p>
   </card>
</wml>
</xsl:template>
</xsl:stylesheet>


Now when I ran this manually using the James Clark XT it produces the
correct code as follows:

command: java -Dcom.jclark.xsl.sax.parser=com.sun.xml.parser.Parser
              com.jclark.xsl.sax.Driver atest.xml atestWML.xsl welcome.wml

WML
---
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.com/DTD/wml_1.1.xml">
<wml>
<card id="main1" title="main card">
<onevent type="ontimer">
<go href="http://localhost:8080/jsp/mainmenu.jsp"/>
</onevent>
<timer value="60"/>
<do type="accept" label="next">
<go href="http://localhost:8080/jsp/mainmenu.jsp"/>
</do>
<do type="prev">
<noop/>
</do>
<p>Welcome Ben Sifuentes to AirBank!</p>
</card>
</wml>


Now on the other hand when I use the XT demo code "DOMDemo" that comes with
the XT installation. It produces incorrect output!

WML
---
<?xml version="1.0" encoding="UTF-8"?>

<wml>
  <card id="main1" title="main card">
    <onevent type="ontimer">
      <go href="http://localhost:8080/jsp/mainmenu.jsp" />
    </onevent>
    <timer value="60" />
    <do type="accept" label="next">
      <go href="http://localhost:8080/jsp/mainmenu.jsp" />
    </do>
    <do type="prev">
      <noop />
    </do>
    <p>Welcome Ben Sifuentes to AirBank!</p>
  </card>
</wml>

As you can see from the above. The <!DOCTYPE ...> is missing from the file
that was generated. It should have been on the second line. I've included
the DOMDemo.java code.

DOMDemo.java
------------
import java.io.IOException;
import java.io.OutputStream;
import java.io.FileOutputStream;
import org.xml.sax.SAXException;
import com.sun.xml.tree.XmlDocument;

import com.jclark.xsl.dom.Transform;
import com.jclark.xsl.dom.TransformEngine;
import com.jclark.xsl.dom.TransformException;
import com.jclark.xsl.dom.XSLTransformEngine;

/**
 * This is a demo of using the simple, pure DOM API to XT.
 * It uses Sun's DOM implementation (Project X TR2).
 */

class DOMDemo {
  public static void main(String[] args)
    throws IOException, SAXException, TransformException {
    if (args.length != 3) {
      System.err.println("usage: java DOMDemo sourceURL stylesheetURL
resultFile");
      System.exit(1);
    }

    XmlDocument result = new XmlDocument();
    new XSLTransformEngine()
      .createTransform(XmlDocument.createXmlDocument(args[1], false))
      .transform(XmlDocument.createXmlDocument(args[0]),
		 result);
    OutputStream out = new FileOutputStream(args[2]);
    result.write(out);
    out.close();
  }
}


Now I realize that when I ran it from the command line it was using SAX to
parser the file and generate the ouput and that the java code is using DOM
to produce it's output. But, from my understanding it should have produced
the same output. Also can anyone guide me in modifying the above code to
utilize SAX instead of the DOM.

Any help would be greatly appreciated.
-Ben


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.