libxml, txmlreader.fromdoc & loadtext
BlitzMax Forums/Brucey's Modules/libxml, txmlreader.fromdoc & loadtext
| ||
I'm loading xml from a zip using the zipstream mod, and it seems there is a format mixup trying to load the xml data using loadtext:Local file:String = "zip::gui\base.fui//Panels/pnl_nil.xml" Local reader:TxmlTextReader If file.ToLower().StartsWith("zip::") reader = TxmlTextReader.fromDoc(LoadText(file), file, Null, 0) Else reader = TxmlTextReader.FromFile(file) 'for backwards compatibility End If 'read nodes... At 'reader = TxmlTextReader.FromFile(file)' (not loading from .zip/.fui) it was fine, but thats because libxml was handling the reading. When loading from a zip/fui I get errors like these (xml was saved from blitzmax code): zip::gui\base.fui//Panels/pnl_nil.xml:1: parser error : ParsePI: PI xm space expected <?xm ^ zip::gui\base.fui//Panels/pnl_nil.xml:1: parser error : ParsePI: PI xm never end ... <?xm ^ The xml file: |
| ||
can you output what LoadText(file) is returning? See if it looks okay. |
| ||
Doesn't seem any different then the actual file.. (but in notepad the actual xml file has block characters instead of newlines, they got converted to newline chars when I pasted them in - the first post) EDIT: And I've tried using "UTF-8", "ISO-8859-1", "UTF-16" and "windows-1252" as the encoding for reader.fromdoc() EDIT2: LoadText() uses "LATIN-1" as the file format if it couldn't figure it out by the first few bytes, I don't know how the file encoding stuff works, but are the first few bytes supposed to represent the encoding? or is that just a blitzmax featuree? |
| ||
Hmmm.. looks the same ;-) Wanna mail me an example zipped file and a pointer to the zipstream module? Thanks :-) |
| ||
http://files.filefront.com/wxdesigner+6+26+08+prezip/;10813030;/fileinfo.html You'll need bufferedstream and zipstream: http://www.koriolis-fx.com/forum/index.php?board=6.0 Add the frydwx module and try to run 'gui\zipstream_test.bmx'. The code that reads the xml files is in 'frydwx.mod\xmlfrygui.mod\xmlfrygui.bmx' - see the parse functions. Sorry about the whole mess of things.. that's because I start doing tests and then they become my working codebase :D EDIT: Totally missed "mail me".. no matter! its (and will be released as) open source code anyways. |
| ||
I start doing tests and then they become my working codebase Me too :-) First to see if I can get everything to build ! |
| ||
I need to sign up... :-p getting there! |
| ||
oh, btw... just for interests sake... since you are using wxMax anyway... did you know that it has various streaming modules, like zip, rar, bzip, etc... samples are there to play with too... :-p |
| ||
Oh... and don't forget it needs zipengine... |
| ||
Hmm... loading okay here (on Mac, and admitedly on the latest libxml).. I'll try the current SVN libxml and see what happens. |
| ||
Oh... and don't forget it needs zipengine... Woops.. zipengine and zipstream need to be built into one module, seeing as they're compiling the same zlib code twice. Hmm... loading okay here (on Mac, and admitedly on the latest libxml).. Hrm.. you checked the output right? no libxml errors? I'll try the current SVN libxml and see what happens. I'm on v1.13. |
| ||
oh... no gadgets... it borks before it gets that far even :-) GetColor() blows with a nullpointer... looks like there's no GL context made yet. stack looks like : GetColor Push Refresh SetXAlign Create fry_CreateLabel ParseGadget ParseGadget ParsePanelFile ParsePanels fry_fui_ParseGUI quite possible on Mac you are getting a a slightly different order... |
| ||
Remove the setgraphicsdriver() call, I never actually got it to show gadgets, I had it showing a few buttons the guitest.. lemme rewrite the code. EDIT: In wxgui_fdcnv.bmx change the line: Function LoadScreen(base:String = "gui\base", Clear:Int = False) to ... Function LoadScreen(base:String = "gui\base.fui", Clear:Int = False) and then try to run guitest.bmx, I get the libxml errors and then a "Unhandled Exception:Illegal operation on empty list" error. But if you can actually load in the gadgets it should work. |
| ||
okay... I get libxml errors with that. Will have a look. |
| ||
It would be better for it to use the wxzip stuff, but I don't see any capabilities for finding folder hierarchy. Actually the code for wxzipinput/outputstream, wxzipfshandler and wxzipentry seem to be stubs. bzip doesn't have any support for folder hierarchy and I don't want to use rar - I want the fui package to be more widely readable. |
| ||
Ah... I see what's up. if you change xmlfrygui to this : ... If file.ToLower().StartsWith("zip::") Local s:String = LoadText(file) reader = TxmlTextReader.fromDoc(s, file, Null, 0) iszip = True ... the errors go away. which implies that the string from LoadText() is being cleaned up or something when passed into that function. Dunno, it's a bit weird. Certainly some reference isn't lasting long enough for the call. |
| ||
seem to be stubs. So they do.... why is it that I'd thought I'd worked on those then... (I'll need to sort that out!) The fshandler would let you use "urls" like you have already. Stick with what you have for now :-) |
| ||
Oh bugger! and I usually do local scope variables for things like that, thanks. The fshandler would let you use "urls" like you have already. Figured. I'll need to sort that out! I'll wait :D |
| ||
Uhoh.. still not working (on WindowsXP, typical) All ziploading changed to this: Local xmldata:String = LoadText(file) DebugLog xmldata reader = TxmlTextReader.fromDoc(xmldata, file, Null, 0) It loads up and ONLY shows a label (there are alot more gadgets then just one label) Output: Then when I close the frame it pops up with a "RuntimeError" message: COMMAND::"C:/Program Files/BlitzMax/bin/bmk.exe" makeapp -x -d -a -o C:/cstruct/code/lang/bmax/projects/fryDesigner/designer/wx/fb/guitest.debug C:/cstruct/code/lang/bmax/projects/fryDesigner/designer/wx/fb/guitest.bmx zip::gui\base.fui//Panels/pnl_nil.xml:4: parser error : attributes construct error .0" font="Default" hide="false" length="150" align="1" start="0" end="6" inc="1" ^ zip::gui\base.fui//Panels/pnl_nil.xml:4: parser error : Couldn't find end of Start Tag slider And only a few times the program crashed saying "Unhandled Memory Exception Error", sounds like GC is kicking in?? Even changing the location of xmldata:String above the if statement I still get an empty list error. |
| ||
AHHA! found it.. silly, very silly. Comment out the MemFree ('cStr1' and 'cStr2') calls in TxmlTextReader.fromDoc() and it seems to be loading just fine.. |
| ||
Ah, of course... since it needs to hang onto the string during the reading of the xml.. Interesting conundrum then... Looks like the text will need to be referenced in the type until the object is Free()'d. Sorry for the trouble. |