I have a main.lua in which I download some XML from a webservice, add an XSLT reference element to the front of the file and save it to the system.TemporaryDirectory.
At program start, it copies an XSLT file from the system.ResourceDirectory to the system.TemporaryDirectory.
Once all that is done, and I can see it is by dumping it all into a textbox, I open up a web popup and give it the URL of the XML file in the system.TemporaryDirectory.
All I get is a grey box and I don’t know why. My code is below, minus the proprietary web service URLs, I’m afraid…
Matt.
[lua]display.setStatusBar( display.HiddenStatusBar ) – guess what this does
– displays all XML downloaded in one textbox in the top 3rd of the screen
local textbox = native.newTextBox( 0, 0, display.contentWidth, display.contentHeight/3 )
– takes a fresh copy of the XSLT files from the app’s directory and puts them in the tmp dir
function copy( source, dest )
local rpath = system.pathForFile( source, system.ResourceDirectory )
local rfile = io.open( rpath, “r” )
local str = “”
if (rfile) then
str = rfile:read("*l")
io.close( rfile )
end
local wpath = system.pathForFile( dest, system.TemporaryDirectory )
local wfile = io.open( wpath, “w” )
wfile:write( str )
io.close( wfile )
end
copy( “feed.xslt”, “feed.xslt” )
copy( “article.xslt”, “article.xslt” )
function save( filename, insert, content )
if (insert) then
textbox.text = textbox.text … insert
end
local path = system.pathForFile( filename, system.TemporaryDirectory )
local file = io.open( path, “w” )
if (insert) then
file:write( insert )
end
file:write( content )
io.close( file )
end
– dumps first XML block into text box in top 3rd of screen
function renderlogon( event )
print(“RENDER LOGON…”)
print(event.response)
save( “logon.xml”, nil, event.response )
textbox.text = event.response
print(“END”)
network.request( FEEDURL, “GET”, renderfeed )
end
– dumps second XML block into web popup in the middle 3rd of the screen
function renderfeed( event )
local xslt = ‘<?xml-stylesheet type="text/xsl" href="feed.xslt"?>’
print(“RENDER FEED…”)
print(event.response)
save( “feed.xml”, xslt, event.response )
textbox.text = textbox.text … event.response
native.showWebPopup( 0, display.contentHeight/3, display.contentWidth, display.contentHeight/3, “feed.xml”, {base=system.TemporaryDirectory} )
print(“END”)
network.request( ARTICLEURL, “GET”, renderarticle )
end
– dumps the last XML block into web popup in the bottom 3rd of the screen
function renderarticle( event )
local xslt = ‘<?xml-stylesheet type="text/xsl" href="article.xslt"?>’
print(“RENDER ARTICLE…”)
print(event.response)
save( “article.xml”, xslt, event.response )
textbox.text = textbox.text … event.response
native.showWebPopup( 0, (display.contentHeight/3)*2, display.contentWidth, display.contentHeight/3, “article.xml”, {base=system.TemporaryDirectory} )
print(“END”)
end
network.request( LOGONURL, “GET”, renderlogon )[/lua]
[import]uid: 8271 topic_id: 6348 reply_id: 306348[/import]
[import]uid: 8271 topic_id: 6348 reply_id: 23600[/import]