[android-developers] Re: Loading from a compiled xml file

2010-07-01 Thread piyu

Hi John,

  Can copy here code to know how you are reading fron input stream.

 Thanks in advance.

On Jul 1, 12:36 am, RespeckKnuckles (John Licato)
respeckknuckl...@gmail.com wrote:
 Hey guys,

 I have some xml files with a custom format (based on the scxml
 specifications) that I want my program to read. I've already written
 the code to read it, but I'm running into problems actually reading
 the file itself. I want the file to be compiled with the apk, as it
 will not be changed at all during run time. So I put the file
 (test.xml) in the res/xml/ folder, and got the inputstream by using:

 getResources().openRawResource(R.xml.test);

 but when I read in this inputstream it is complete jibberish, which
 makes me suspect it is being read in binary, as openRawResource() is
 often used for binary files like images, if I am correct. What is the
 correct way to do this?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Loading from a compiled xml file

2010-07-01 Thread RespeckKnuckles (John Licato)
Hey guys,

I put the xml file into the res/raw directory and it works better, but
still not working completely. Here is the code I'm using:

InputStream toParse = 
getResources().openRawResource(R.raw.test); //
file is in res/raw/test.xml
DocumentBuilder db =

DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document d = db.parse(toParse);
Element rootElement = d.getDocumentElement();

It fails at db.parse(), saying Unexpected end of document found.
I've converted the toParse stream into a string and verified it is
correct, and I simplified it so that the only xml it reads is:

HTML/HTML

and it still says the same thing. This may be more of a java DOM
issue, but do any of you have any ideas?

On Jul 1, 1:42 am, piyu spk2p...@gmail.com wrote:
 Hi John,

   Can copy here code to know how you are reading fron input stream.

  Thanks in advance.

 On Jul 1, 12:36 am, RespeckKnuckles(John Licato)



 respeckknuckl...@gmail.com wrote:
  Hey guys,

  I have some xml files with a custom format (based on the scxml
  specifications) that I want my program to read. I've already written
  the code to read it, but I'm running into problems actually reading
  the file itself. I want the file to be compiled with the apk, as it
  will not be changed at all during run time. So I put the file
  (test.xml) in the res/xml/ folder, and got the inputstream by using:

  getResources().openRawResource(R.xml.test);

  but when I read in this inputstream it is complete jibberish, which
  makes me suspect it is being read in binary, as openRawResource() is
  often used for binary files like images, if I am correct. What is the
  correct way to do this?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Loading from a compiled xml file

2010-07-01 Thread RespeckKnuckles (John Licato)
Just in case the ?xml ? element was the problem, I tried this xml
code instead:

?xml version=1.0 encoding=utf-8?
HTML/HTML

and still didn't work.

On Jul 1, 12:46 pm, RespeckKnuckles (John Licato)
respeckknuckl...@gmail.com wrote:
 Hey guys,

 I put the xml file into the res/raw directory and it works better, but
 still not working completely. Here is the code I'm using:

                         InputStream toParse = 
 getResources().openRawResource(R.raw.test); //
 file is in res/raw/test.xml
                         DocumentBuilder db =
                                 
 DocumentBuilderFactory.newInstance().newDocumentBuilder();
                         Document d = db.parse(toParse);
                         Element rootElement = d.getDocumentElement();

 It fails at db.parse(), saying Unexpected end of document found.
 I've converted the toParse stream into a string and verified it is
 correct, and I simplified it so that the only xml it reads is:

 HTML/HTML

 and it still says the same thing. This may be more of a java DOM
 issue, but do any of you have any ideas?

 On Jul 1, 1:42 am, piyu spk2p...@gmail.com wrote:



  Hi John,

    Can copy here code to know how you are reading fron input stream.

   Thanks in advance.

  On Jul 1, 12:36 am, RespeckKnuckles(John Licato)

  respeckknuckl...@gmail.com wrote:
   Hey guys,

   I have some xml files with a custom format (based on the scxml
   specifications) that I want my program to read. I've already written
   the code to read it, but I'm running into problems actually reading
   the file itself. I want the file to be compiled with the apk, as it
   will not be changed at all during run time. So I put the file
   (test.xml) in the res/xml/ folder, and got the inputstream by using:

   getResources().openRawResource(R.xml.test);

   but when I read in this inputstream it is complete jibberish, which
   makes me suspect it is being read in binary, as openRawResource() is
   often used for binary files like images, if I am correct. What is the
   correct way to do this?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: Loading from a compiled xml file

2010-07-01 Thread Mark Murphy
Put it back in res/xml/. Use getResources().getXml() to get an
XmlPullParser on the file.

On Thu, Jul 1, 2010 at 2:47 PM, RespeckKnuckles (John Licato)
respeckknuckl...@gmail.com wrote:
 Just in case the ?xml ? element was the problem, I tried this xml
 code instead:

 ?xml version=1.0 encoding=utf-8?
 HTML/HTML

 and still didn't work.

 On Jul 1, 12:46 pm, RespeckKnuckles (John Licato)
 respeckknuckl...@gmail.com wrote:
 Hey guys,

 I put the xml file into the res/raw directory and it works better, but
 still not working completely. Here is the code I'm using:

                         InputStream toParse = 
 getResources().openRawResource(R.raw.test); //
 file is in res/raw/test.xml
                         DocumentBuilder db =
                                 
 DocumentBuilderFactory.newInstance().newDocumentBuilder();
                         Document d = db.parse(toParse);
                         Element rootElement = d.getDocumentElement();

 It fails at db.parse(), saying Unexpected end of document found.
 I've converted the toParse stream into a string and verified it is
 correct, and I simplified it so that the only xml it reads is:

 HTML/HTML

 and it still says the same thing. This may be more of a java DOM
 issue, but do any of you have any ideas?

 On Jul 1, 1:42 am, piyu spk2p...@gmail.com wrote:



  Hi John,

    Can copy here code to know how you are reading fron input stream.

   Thanks in advance.

  On Jul 1, 12:36 am, RespeckKnuckles(John Licato)

  respeckknuckl...@gmail.com wrote:
   Hey guys,

   I have some xml files with a custom format (based on the scxml
   specifications) that I want my program to read. I've already written
   the code to read it, but I'm running into problems actually reading
   the file itself. I want the file to be compiled with the apk, as it
   will not be changed at all during run time. So I put the file
   (test.xml) in the res/xml/ folder, and got the inputstream by using:

   getResources().openRawResource(R.xml.test);

   but when I read in this inputstream it is complete jibberish, which
   makes me suspect it is being read in binary, as openRawResource() is
   often used for binary files like images, if I am correct. What is the
   correct way to do this?

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en




-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android Training...At Your Office: http://commonsware.com/training

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Loading from a compiled xml file

2010-07-01 Thread Bob Kerns
Sure. Design some XML language -- the one Google used for layouts
would work but is rather complex and not focused on your particular
problem -- and I think you'd have to reimplement it to use non-
compressed XML. There's probably no need to give the server the
ability to design completely arbitrary screens anyway.

You might be able to leverage an existing dependency-injection
package, like Spring.

Then load this XML language and interpret it -- creating, adding, and
configuring views as indicated by the XML.

A HUGE downside to anything like this, is that you lose the ability to
customize and localize the layout. So you may want to consider passing
the screen resolution and size, language, and other potentially-
relevant information to the server, so the server can potentially
(possibly after release of the client) make decisions based on this
information.

On Jun 30, 10:53 pm, ABhi abhishek.gonda...@gmail.com wrote:
 I'm not sure if i understand the question correctly. My need is
 slightly different for dynamic screen generation.

 Hi All,

 I'm dealing with a problem you guys might not have faced earlier.

 I'm having a use-case in my Android application where the actual
 screen that i want to show to user is not stored in any layout file of
 my application. The layout of the of the screen is designed by server
 in this case, based on selection made by user on first screen.

 Let me elaborate here,
 1st Screen : List of check box with different biller names.  (Imagine
 i've selected 2 billers from this screen)

 2nd Screen :  (The screen that server has decided how it should look
 like)
 * Header,
 * 1st Biller name (Label)
 * Amount for 1st Biller TextBox
 * Image (a Separator image)
 * 2st Biller name (Label)
 * Amount for 2st Biller TextBox.
 * Here there can be a checbox/radio/another TextBox anything.
 * Image (a Separator image)
 * Button (to submit above form back to server)

 I hope makes some sense in what i'm planning to design.

 -
 The current issues i'm dealing with are as below.
 1). How to draw this dynamic widgets?
 2). How to fetch user Inputs from this dynamically created widgets?

 Thanks in advance.
 Regards
 Abhishek

 On Jul 1, 9:51 am, Bob Kerns r...@acm.org wrote:



  Don't put it in the xml/ directory. That does indeed get compiled into
  a binary format, and you'd need to use the corresponding API for
  reading it.

  (Or you could recode to use that API, and gain efficiency and space --
  but first, you'd like to test the code you've already written, right?)

  So put your test.xml into the raw/ directory instead of the xml/
  directory (and use R.raw.test).

  More info 
  here:http://developer.android.com/intl/de/guide/topics/resources/providing...

  And if you want to move it back and get the benefits of using the
  compiled format, you'll access it starting with this 
  API:http://developer.android.com/intl/de/reference/android/content/res/Re...)

  On Jun 30, 12:36 pm, RespeckKnuckles (John Licato)

  respeckknuckl...@gmail.com wrote:
   Hey guys,

   I have some xml files with a custom format (based on the scxml
   specifications) that I want my program to read. I've already written
   the code to read it, but I'm running into problems actually reading
   the file itself. I want the file to be compiled with the apk, as it
   will not be changed at all during run time. So I put the file
   (test.xml) in the res/xml/ folder, and got the inputstream by using:

   getResources().openRawResource(R.xml.test);

   but when I read in this inputstream it is complete jibberish, which
   makes me suspect it is being read in binary, as openRawResource() is
   often used for binary files like images, if I am correct. What is the
   correct way to do this?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Loading from a compiled xml file

2010-07-01 Thread Bob Kerns
No idea off the top of my head, other than that something you think is
true probably isn't. Not exactly a helpful observation...

But why not try HTML/ instead of HTML/HTML, and verify that
you're getting that. They're equivalent, but going to even simpler XML
may lead you to discover the problem by getting you to go through
things again.

Make sure you didn't accidentally leave in the code to read from the
stream and print it out!

Also, make sure your input file is in utf-8. (Which in this case, is
the same as ASCII/IS0-646). You may have used some editing tool that
put it in UTF-16. Or perhaps there's a byte-order mark inserted, and
perhaps the parser doesn't handle that properly.

On Jul 1, 10:46 am, RespeckKnuckles (John Licato)
respeckknuckl...@gmail.com wrote:
 Hey guys,

 I put the xml file into the res/raw directory and it works better, but
 still not working completely. Here is the code I'm using:

                         InputStream toParse = 
 getResources().openRawResource(R.raw.test); //
 file is in res/raw/test.xml
                         DocumentBuilder db =
                                 
 DocumentBuilderFactory.newInstance().newDocumentBuilder();
                         Document d = db.parse(toParse);
                         Element rootElement = d.getDocumentElement();

 It fails at db.parse(), saying Unexpected end of document found.
 I've converted the toParse stream into a string and verified it is
 correct, and I simplified it so that the only xml it reads is:

 HTML/HTML

 and it still says the same thing. This may be more of a java DOM
 issue, but do any of you have any ideas?

 On Jul 1, 1:42 am, piyu spk2p...@gmail.com wrote:



  Hi John,

    Can copy here code to know how you are reading fron input stream.

   Thanks in advance.

  On Jul 1, 12:36 am, RespeckKnuckles(John Licato)

  respeckknuckl...@gmail.com wrote:
   Hey guys,

   I have some xml files with a custom format (based on the scxml
   specifications) that I want my program to read. I've already written
   the code to read it, but I'm running into problems actually reading
   the file itself. I want the file to be compiled with the apk, as it
   will not be changed at all during run time. So I put the file
   (test.xml) in the res/xml/ folder, and got the inputstream by using:

   getResources().openRawResource(R.xml.test);

   but when I read in this inputstream it is complete jibberish, which
   makes me suspect it is being read in binary, as openRawResource() is
   often used for binary files like images, if I am correct. What is the
   correct way to do this?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Loading from a compiled xml file

2010-07-01 Thread Bob Kerns
That's a good thing to do, but he'll have to rewrite his code. It
would be wise to test that his existing code is working as a baseline,
and check it in to revision control, and write a few unit tests,
before doing that.

Unless his code is trivial, of course. Or his head gets too bloody
from pounding his head against a brick wall...

On Jul 1, 12:04 pm, Mark Murphy mmur...@commonsware.com wrote:
 Put it back in res/xml/. Use getResources().getXml() to get an
 XmlPullParser on the file.

 On Thu, Jul 1, 2010 at 2:47 PM, RespeckKnuckles (John Licato)





 respeckknuckl...@gmail.com wrote:
  Just in case the ?xml ? element was the problem, I tried this xml
  code instead:

  ?xml version=1.0 encoding=utf-8?
  HTML/HTML

  and still didn't work.

  On Jul 1, 12:46 pm, RespeckKnuckles (John Licato)
  respeckknuckl...@gmail.com wrote:
  Hey guys,

  I put the xml file into the res/raw directory and it works better, but
  still not working completely. Here is the code I'm using:

                          InputStream toParse = 
  getResources().openRawResource(R.raw.test); //
  file is in res/raw/test.xml
                          DocumentBuilder db =
                                  
  DocumentBuilderFactory.newInstance().newDocumentBuilder();
                          Document d = db.parse(toParse);
                          Element rootElement = d.getDocumentElement();

  It fails at db.parse(), saying Unexpected end of document found.
  I've converted the toParse stream into a string and verified it is
  correct, and I simplified it so that the only xml it reads is:

  HTML/HTML

  and it still says the same thing. This may be more of a java DOM
  issue, but do any of you have any ideas?

  On Jul 1, 1:42 am, piyu spk2p...@gmail.com wrote:

   Hi John,

     Can copy here code to know how you are reading fron input stream.

    Thanks in advance.

   On Jul 1, 12:36 am, RespeckKnuckles(John Licato)

   respeckknuckl...@gmail.com wrote:
Hey guys,

I have some xml files with a custom format (based on the scxml
specifications) that I want my program to read. I've already written
the code to read it, but I'm running into problems actually reading
the file itself. I want the file to be compiled with the apk, as it
will not be changed at all during run time. So I put the file
(test.xml) in the res/xml/ folder, and got the inputstream by using:

getResources().openRawResource(R.xml.test);

but when I read in this inputstream it is complete jibberish, which
makes me suspect it is being read in binary, as openRawResource() is
often used for binary files like images, if I am correct. What is the
correct way to do this?

  --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to android-developers@googlegroups.com
  To unsubscribe from this group, send email to
  android-developers+unsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

 Android Training...At Your Office:http://commonsware.com/training

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Loading from a compiled xml file

2010-06-30 Thread Bob Kerns
Don't put it in the xml/ directory. That does indeed get compiled into
a binary format, and you'd need to use the corresponding API for
reading it.

(Or you could recode to use that API, and gain efficiency and space --
but first, you'd like to test the code you've already written, right?)

So put your test.xml into the raw/ directory instead of the xml/
directory (and use R.raw.test).

More info here:
http://developer.android.com/intl/de/guide/topics/resources/providing-resources.html

And if you want to move it back and get the benefits of using the
compiled format, you'll access it starting with this API:
http://developer.android.com/intl/de/reference/android/content/res/Resources.html#getXml(int)


On Jun 30, 12:36 pm, RespeckKnuckles (John Licato)
respeckknuckl...@gmail.com wrote:
 Hey guys,

 I have some xml files with a custom format (based on the scxml
 specifications) that I want my program to read. I've already written
 the code to read it, but I'm running into problems actually reading
 the file itself. I want the file to be compiled with the apk, as it
 will not be changed at all during run time. So I put the file
 (test.xml) in the res/xml/ folder, and got the inputstream by using:

 getResources().openRawResource(R.xml.test);

 but when I read in this inputstream it is complete jibberish, which
 makes me suspect it is being read in binary, as openRawResource() is
 often used for binary files like images, if I am correct. What is the
 correct way to do this?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Loading from a compiled xml file

2010-06-30 Thread ABhi
I'm not sure if i understand the question correctly. My need is
slightly different for dynamic screen generation.

Hi All,

I'm dealing with a problem you guys might not have faced earlier.

I'm having a use-case in my Android application where the actual
screen that i want to show to user is not stored in any layout file of
my application. The layout of the of the screen is designed by server
in this case, based on selection made by user on first screen.

Let me elaborate here,
1st Screen : List of check box with different biller names.  (Imagine
i've selected 2 billers from this screen)

2nd Screen :  (The screen that server has decided how it should look
like)
* Header,
* 1st Biller name (Label)
* Amount for 1st Biller TextBox
* Image (a Separator image)
* 2st Biller name (Label)
* Amount for 2st Biller TextBox.
* Here there can be a checbox/radio/another TextBox anything.
* Image (a Separator image)
* Button (to submit above form back to server)

I hope makes some sense in what i'm planning to design.

-
The current issues i'm dealing with are as below.
1). How to draw this dynamic widgets?
2). How to fetch user Inputs from this dynamically created widgets?


Thanks in advance.
Regards
Abhishek


On Jul 1, 9:51 am, Bob Kerns r...@acm.org wrote:
 Don't put it in the xml/ directory. That does indeed get compiled into
 a binary format, and you'd need to use the corresponding API for
 reading it.

 (Or you could recode to use that API, and gain efficiency and space --
 but first, you'd like to test the code you've already written, right?)

 So put your test.xml into the raw/ directory instead of the xml/
 directory (and use R.raw.test).

 More info 
 here:http://developer.android.com/intl/de/guide/topics/resources/providing...

 And if you want to move it back and get the benefits of using the
 compiled format, you'll access it starting with this 
 API:http://developer.android.com/intl/de/reference/android/content/res/Re...)

 On Jun 30, 12:36 pm, RespeckKnuckles (John Licato)



 respeckknuckl...@gmail.com wrote:
  Hey guys,

  I have some xml files with a custom format (based on the scxml
  specifications) that I want my program to read. I've already written
  the code to read it, but I'm running into problems actually reading
  the file itself. I want the file to be compiled with the apk, as it
  will not be changed at all during run time. So I put the file
  (test.xml) in the res/xml/ folder, and got the inputstream by using:

  getResources().openRawResource(R.xml.test);

  but when I read in this inputstream it is complete jibberish, which
  makes me suspect it is being read in binary, as openRawResource() is
  often used for binary files like images, if I am correct. What is the
  correct way to do this?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en