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 July 3rd, 2008, 04:39 PM
Registered User
 
Join Date: Jul 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSLTProcessor and Blackberry browser

Hi, is there a way to make this code render on a blackberry browser?

Code:
<script>
if(window.ActiveXObject){
// IE

// Load XML
xml = new ActiveXObject("MSXML2.DOMDocument");
xml.async = false
xml.load("ONXX.xml")

// Load XSL
xsl = new ActiveXObject("MSXML2.DOMDocument");
xsl.async = false
xsl.load("displayquote.xsl")


// Transform
document.getElementById("example").innerHTML=xml.transformNode(xsl);
}else if(document.implementation && document.implementation.createDocument){
// Mozilla

var xsltProcessor = new XSLTProcessor();

// load the xslt file
var myXMLHTTPRequest = new XMLHttpRequest();
myXMLHTTPRequest.open("GET", "displayquote.xsl", false);
myXMLHTTPRequest.send(null);

// get the XML document
xslStylesheet = myXMLHTTPRequest.respon****ML;
xsltProcessor.importStylesheet(xslStylesheet);

// load the xml file
myXMLHTTPRequest = new XMLHttpRequest();
myXMLHTTPRequest.open("GET", "ONXX.xml", false);
myXMLHTTPRequest.send(null);

var xmlSource = myXMLHTTPRequest.respon****ML;

//transform
 var resultDocument = xsltProcessor.transformToFragment(xmlSource, document);
document.getElementById("example").appendChild(resultDocument);

}else{
// Browser unknown
alert("Browser unknown");
}


</script>
Currently the code looks like it is just skipped by the browser. Thanks!

-K
 
Old July 3rd, 2008, 05:24 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

I very much doubt the BlackBerry browser has the ability to create COM objects via client-side script.

--

Joe (Microsoft MVP - XML)
 
Old July 3rd, 2008, 06:55 PM
Registered User
 
Join Date: Jul 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Is there an equivalent to getting xml to render on the bb browser?
 
Old July 4th, 2008, 03:25 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

I'm going to hazard a guess and say that you would get a better answer to that question on a Blackberry specific forum than on this one. I believe RIM themselves have a set of developer forums.

/- Sam Judson : Wrox Technical Editor -/
 
Old September 16th, 2008, 06:47 AM
Registered User
 
Join Date: Sep 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Use any server side program instead of client side like jsp/asp.

Also use transformation technique with xsl and xml to generate html.

Thanks,
Felix Baskar.
Sr Application Development Consultant
Emantras Inc.

 
Old September 16th, 2008, 06:52 AM
Registered User
 
Join Date: Sep 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Also i tried with servlet its working fine.
Please find the code below ,


  public void doGet(HttpServletRequest req, HttpServletResponse res)
            throws ServletException, IOException {
        try {
        // get the filename of the XSLT stylesheet
        String xsltName = req.getParameter("xslt");

        if (xsltName == null) {
            throw new ServletException("xslt is a required parameter");
        }

        ServletContext ctx = getServletContext();
        InputStream xmlIn = ctx.getResourceAsStream("/hello.xml");
        InputStream xsltIn = ctx.getResourceAsStream(xsltName);
        //InputStream xsltIn = ctx.getResourceAsStream("/hello.xsl");

            // show how to read from a system identifier and a Reader
            Source xmlSource = new StreamSource(xmlIn);
            Source xsltSource = new StreamSource(xsltIn);

            res.setContentType("text/html");
            Result result = new StreamResult(res.getOutputStream());

            // get the factory
            TransformerFactory transFact = TransformerFactory.newInstance();

            // get a transformer for this particular stylesheet
            Transformer trans = transFact.newTransformer(xsltSource);

            // do the transformation
            trans.transform(xmlSource, result);
        } catch (Exception ex) {
            ex.printStackTrace();
            throw new ServletException(ex);
        }
    }
Thanks,

Felix Baskar.
Sr Application Development Consultant
Emantras Inc.










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