[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] XML to WML translation
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! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|