AH shoot...
Ok thanks everyone for the replys, I know I didn't add enough info here... So now I am going to just paste my code. Sorry for the lengthy post but it's about all I can do now... What I am trying to do is build a tree from certain tables in my DB. So for instance, I create tags (table names) in my script. I then have a lookup that grabs all customers from that table, iterates through them and creates sub nodes to display in the tree.

I used concepts from Sarah's code and also another demo stack I found that builds the actual tree with icons and wot not.. In Sarah's demo stack however, she removes spaces (as illegal characters in a "Tag Name"). This is where the problem comes in because some of the customers in my table have spaces in their names.

I'm clearly a newbie so I'm sure it's something silly I'm doing but I'd sure appreciate your assistance but what happens is instead of showing
- Customers
     Bokomo Botswana
it only display the first part of the sub node "Bokomo"

the xml below is produced as a result of the code in the mouseUp handler beneath it. It is then sent to a field whose code is stored in the attached txt file.

<?xml version="1.0"?>
<allTables>
<Customers IDnum="19">
 <Bokomo Botswana>
 </Bokomo Botswana>
 <BOTEC>
 </BOTEC>
 <Gemini Logistics>
 </Gemini Logistics>
</Customers>
</allTables>

*****************************************************************************
on mouseUp
 put empty into tTables

 if the hilited of btn "Customers" is true then
   put "Customers"&comma after tTables
 end if

 if the last char of tTables is comma then delete the last char of tTables

 put empty into fld "XMLText"
 put "/allTables" into tParentNode
 put "<allTables></allTables>" into tData

 get revCreateXMLTree(tData, false, true, false)
 checkForError it

 -- store the newly created tree's document ID
 put it into tDocID
 put tDocID into fld "DocID"

 repeat for each item thisI in tTables
   put format ("SELECT * FROM %s",thisI) into tSQL
   try
     get libdb_getTableRecords(theDB, tDataA, tSQL)
   catch er
     if item 1 of er = "lidberr" then
       delete item 1 of er
       answer "Database error:"&& er
       exit to top
     else
       answer "An Error Occurred:" && er
       exit to top
     end if
   end try

   -- add the parent element for the new data record and check for error
   revAddXMLNode tDocID, tParentNode, thisI, ""
   put the result into tSubNode
   checkForError tSubNode
   repeat with i = 1 to tDataA["Length"]
     switch thisI

     case "customers"
       put "companyName" into tPrimary
       put "companyNo,contactPerson,officePh,email" into tFldList
       break

     end switch

     put tDataA["Data", i, tPrimary] into tFirst
     repeat for each item thisFld in tFldList
       put tDataA["Data", i, thisFld] into t[thisFld]
     end repeat

     revSetXMLAttribute tDocID, tSubNode, "IDnum", i
     checkForError the result

     revAddXMLNode tDocID, tSubNode, tFirst, ""
     checkForError the result
     put tSubNode & "/" & tFirst into tSubNode1

   -- format & display the text version of the new XML document
   put formatXMLtext(tDocID) into fld "XMLtext"
   set the xmlstring of fld "xmlTree" to fld "XMLtext"
 end repeat

end mouseUp
******************************************************************************************
Regards
Nic

----- Original Message ----- From: "Joel Guillod" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, May 02, 2007 6:58 PM
Subject: Re: XML Tree and spaces


Hello Nic,

Of course you'll get an answer but please, give an exemple of the xml
data and node content you have problem with and the function you use
to retrieve its content. Neither in my own use of xml nor by using
the Sarah's XML Demo stack (http://www.troz.net/Rev/tutorials/
XMLdemo1.rev.gz)for a rapid check, I was able to reproduce the
behavior your mentionned. So please, be more precise...

Joel


Le 2 mai 07 à 14:00, [EMAIL PROTECTED] a écrit :


De : "Nic Prioleau" <[EMAIL PROTECTED]>
[...]
If I create an xml tree and I have spaces in one of the node values, it will only show the first part of the value before the space. Is there anything anyone can tell me here? Am I not allowed to use spaces here? It would seem a bit limiting if I did?!
[...]

_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

#####################################################################################
This e-mail message has been scanned for Viruses and Content and cleared by MailMarshal
#####################################################################################
local sLine
function IsXMLErr @rpResult
 if  item 1 of rpResult is "XMLerr" then return true
 else return false
end IsXMLErr

setProp XMLdocument newdocid
 revDeleteXMLTree the DocID of me
 set the DocID of me to newdocid
 buildtree
end XMLDocument


setprop XMLDispString xmldata
 revDeleteXMLTree the DocID of me
 put revCreateXMLTree(xmldata,"false") into tresult
 if IsXMLErr(tresult) is false then
   set the DocID of me to tresult
   buildtree
 else put tresult into msg
 set the XMLDispString of me to xmldata
end XMLDispString

setprop XMLString xmldata
 revDeleteXMLTree the DispDocID of me
 put revCreateXMLTree(xmldata,"false") into tresult
 if IsXMLErr(tresult) is false then
   set the DispDocID of me to tresult
   --buildtree
 else put tresult into msg
 set the XMLDispString of me to xmldata
end XMLString


on hilitenode selectednode
 if tnode is not empty then
   revSetXMLAttribute the DocID of me,selectednode,"expanded","true"
   buildtree
   set the hilitednode of me to selectednode
   clicktree selectednode,isexpanded
   select line lineoffset(selectednode, the xmlpathlist of me) of me
 end if
end hilitenode

on mouseup
 lock screen
 put scroll of me into oldscroll
 put the hilitedline of me  into sline
 put line sline of the xmlpathlist of me into selectednode
if selectednode is not empty then
   put true into isexpanded
   if  revXMLAttribute( the DocID of me,selectednode,"expanded") is "true" then 
put false into isexpanded
   revSetXMLAttribute the DocID of me,selectednode,"expanded", isexpanded
   buildtree
   set the hilitednode of me to selectednode
   clicktree selectednode,isexpanded
   select line sline of me
   set scroll of me to oldscroll
 end if
 unlock screen
 getNodeValues selectednode
end mouseup

on buildtree
 put the milliseconds into tseconds
 put the DocID of me into docid
 put 0 into depth
 put revXMLRootNode(docid) into curchild
 if IsXMLErr(curchild) is true then
   put curchild into msg
   exit buildtree
 end if
 repeat forever
   put false into wasexpanded
   put empty into nextchild
   if revXMLAttribute(docid,curchild,"expanded") is "true" or depth is 0 then
     put revXMLFirstChild(docid,curchild) into nextchild
     --answer nextchild
     if nextchild is not empty then
       if depth is not 0 then put tab after depthbuffer
       add 1 to depth
       put true into wasexpanded
     end if
   end if
   if nextchild is empty and depth is not 0 then
     put revXMLNextSibling(docid,curchild) into nextchild
     repeat while nextchild is empty and depth is not 0
       put revXMLParent(docid,curchild) into nextchild
       if nextchild is not empty then
         put nextchild into curchild
         subtract 1 from depth
         delete last char of depthbuffer
       end if
       if depth is 0 then
         put empty into nextchild
         exit repeat
       end if
       put revXMLNextSibling(docid,nextchild) into nextchild
     end repeat
   end if
   if nextchild is empty  then exit repeat
   put nextchild into curchild
   put curchild&cr after pathlist
   set the itemdelimiter to "/"
   put "<p>"&depthbuffer after treelist
if revXMLNumberOfChildren(docid,curchild,"",0) > 0 then
     if revXMLAttribute(docid,curchild,"expanded") is not "true"  then put "<img src="&quote&the 
expandimage of me&quote&"> " after treelist
     else  put "<img src="&quote&the collapseimage of me&quote&"> " after 
treelist
   else put "<img src="&quote&the nochildimage of me&quote&"> " after treelist
   put revXMLAttribute(docid,curchild,"icon") into nodeicon
   if IsXMLErr(nodeicon) is false and nodeicon is not empty then put "<img 
src="&quote&nodeicon&quote&"> " after treelist
   if the labelbyname of me is true then put 
revXMLAttribute(docid,curchild,"name")&"</p>"&cr after treelist
   else put item -1 of curchild&"</p>"&cr after treelist
   set the itemdelimiter to comma
 end repeat
 --put the milliseconds - tseconds
 set the htmltext of me to treelist
 delete last char of pathlist
 set the xmlpathlist of me to pathlist
end buildtree


----------------------------------USER DEFINED HANDLERS

on getNodeValues theNode
local tStart, tDocID, tParentNode, tNode, tChild, tFirst, tLast
 put sLine - 1 into tStart
 if tStart < 1 then exit to top
 if tStart is empty then exit to top
put getTreeID() into tDocID
 --put docid into tDocID
 -- setup the display field for text instead of an XML tree
 set the tabStops of fld "XMLtext" to 60
-- find the root tag for this tree
 --addToTranscript "revXMLRootNode(" & tDocID & ")"
 put revXMLRootNode(tDocID) into tParentNode
 --addToTranscript tParentNode
--addToTranscript "revXMLMatchingNode(" & tDocID & ", " & q(theNode) & ", , " & q("IDnum") & ", " & tStart & ", -1)"
 --Nic
 put revXMLMatchingNode(tDocID, theNode, , "IDnum", tStart, -1) into tNode
 --addToTranscript tNode
 put theNode & cr & cr into fld "XMLtext"
--addToTranscript "revXMLChildContents(" & tDocID & ", " & q(tNode) & ", tab, cr, -1)"
 put revXMLChildContents(tDocID, theNode, tab, cr, true, -1) into tChild
 put tChild after fld "XMLtext"
end getNodeValues


on clicktree selectednode,isexpanded
 shownodeinfo
end clicktree
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to