#!/bin/sh # MetaCard 2.4 stack # The following is not ASCII text, # so now would be a good time to q out of more exec mc $0 "$@" W XMLdemo1-- make sure to switch off edit mode when starting -- on openStack send "choose browse tool" to me in 2 ticks end openStack -- close all XML trees and tidy display before closing -- on closeStack if the short name of this stack = "XMLdemo1" then send "mouseUp" to btn "CloseAll" of cd 2 save this stack end if end closeStack -- tidy the display when going to a new card -- on preOpenCard if the short name of this stack = "XMLdemo1" then if there is a fld "Info" then set the vScroll of fld "Info" to 0 if there is a fld "XMLtext" then set the vScroll of fld "XMLtext" to 0 end if end preOpenCard -- debugging handler for locking & unlocking main text field -- on commandKeyDown pKey local tLock if pKey = "l" then put the lockText of fld "Info" into tLock if tLock then set the lockText of fld "Info" to false set the traversalOn of fld "Info" to true else set the lockText of fld "Info" to true set the traversalOn of fld "Info" to false end if else pass commandKeyDown end if end commandKeyDown -- function to return true is system is running Mac OS 9 or less -- this is needed so that the file paths can be translated -- function isMacOS9 if the platform <> "MacOS" then return false set the itemDel to "." if item 1 of the systemVersion < 10 then return true else return false end isMacOS9 -- general XML error checker -- all XML library error messages start with "xmlErr" -- on checkForError pError addToTranscript pError if word 1 of pError contains "xmlErr" then answer error pError as sheet exit to top end if end checkForError -- debugging handler to display XML commands & functions -- and the results of each -- on addToTranscript pString local L, tNewString if pString is empty then put "" into pString if pString contains "XML" is false and pString contains "rev" is false then repeat for each line L in pString put tab & L & cr after tNewString end repeat put tNewString into pString end if put pString & cr after fld "XMLtranscript" of stack "XMLtranscript" set the vScroll of fld "XMLtranscript" of stack "XMLtranscript" to 100000 end addToTranscript -- handler to clear contents of debugging transcript -- on clearTranscript put empty into fld "XMLtranscript" of stack "XMLtranscript" end clearTranscript -- display function to add quotes before & after a string -- function q pString return quote & pString & quote end q -- this is a precautionary routine called whenever one of the demo scripts needs to access the sample data -- if the sample data is not currently loaded into an XML tree, this will load it, beofre returning the document ID -- -- this also clears the transcript display and sets the tabStops of the display field for XML data -- function getTreeID if fld "DocID" is not a number then lock screen send "mouseUp" to btn "Add all the data" of cd "Add" unlock screen end if clearTranscript set the tabStops of fld "XMLtext" to 25 return fld "DocID" end getTreeID -- this handler can be called from any of the info cards -- it just resets the sample data and displays it -- on resetSampleData lock screen send "mouseUp" to btn "Add all the data" of cd "Add" if there is a fld "XMLtext" then put formatXMLText(fld "DocID") into fld "XMLtext" clearTranscript unlock screen end resetSampleData -- custom function for formatting simple XML text data -- it adds linefeeds and indents where appropriate to make the data more readable -- It may not get it exactly right and complex XML files may take a while to process, -- but it should give a better representation than the raw text dump -- function formatXMLtext pDocID local tXML, tMaxLines, tNewXML, tLine, tStartTag, tEndTag, tNextLine, tEndLine local L, x, y put revXMLText(pDocID) into tXML replace "><" with ">" & cr & "<" in tXML replace "" with "/>" & cr in tXML replace "" with "" then get offset(">", tStartTag) put char 1 to it-1 of tStartTag into tStartTag end if put tStartTag into tEndTag put "/" after char 1 of tEndTag if tLine contains tStartTag and tLine contains tEndTag then next repeat put x + 1 into tNextLine get lineOffset(tEndTag, tXML, tNextLine) if it > 0 then put tNextLine + it - 1 into tEndLine repeat with y = tNextLine to tEndLine put tab before line y of tXML end repeat end if end repeat if last char of tXML = cr then delete last char of tXML return tXML end formatXMLtext t cDefaultXML Steve Jobs 001 345 100 Bill Gates 284 666 987 Linus Torvald 43 479 123 Kevin Miller 100 421 987 cVersionNum1.2 XML demo 1 UVerdana UVerdanaUVerdanaWVerdana WVerdanaWVerdanaUVerdana ULucida Grande UCourier UVerdana WVerdana @UVerdana AUVerdana WCourier WCourier UVerdana @UVerdana U Courier New U Courier New UGenevacREVGeometryCachestackID1111cRevStandaloneSettings7scriptLibrariesInternet Geometry PrintingMacOSXtrue OSX,nameXMLdemo1MacOS,documentTypeUNIX,fileSelectortrueWindowsfalseWindows,LegalCopyright#2004 All rights reserved worldwideMacOS,longVersionXMLdemo1 1.0.0.0UNIX,pageSetuptrueOSX,documentTypeLinuxfalseWindows,documenticonFile8/Applications/Revolution 2.2/Sample Icons/genericdoc.icoOdtfalse inclusionssearch answerDialogtrueSPARCfalse SolIntelfalseOSX,documentExtensionWindows,FileDescriptionXMLdemo1 1.0.0.0 for WindowsOSX,longVersionXMLdemo1 1.0.0.0OSX,copyright#2004 All rights reserved worldwideUNIX,printerChoosertrueMacOS,MinimumSize15000MacOS,versionnumber11MacOS,versionnumber20MacOS,ReleaseFinalnameXMLdemo1MacOS,versionnumber30Hp9k700falsers6000false MacOS,Region1OSX,shortVersion1.0.0.0Windows,fileversion11Windows,fileversion20Windows,productversion11Windows,productversion20Windows,fileversion30BsdfalsecursorsfalseWindows,productversion30Windows,fileversion40Windows,productversion40 OSX,infoXMLdemo1 Version 1.0.0.0MacOS,dynamicMemorytrueIrisfalse askDialogtrueWindows,iconFile8/Applications/Revolution 2.2/Sample Icons/genericapp.icoOSX,signature????MacOS,PreferredSize15000Windows,ProductNameXMLdemo1UNIX,colorChoosertrue MacOSPPCtrueWindows,companyname SolSparcfalseMacOS,creator???? cREVGeneral scriptChecksum$qz[,Be debugObjects handlerListopenStack closeStack preOpenCard commandKeyDown isMacOS9 checkForError addToTranscript clearTranscript q getTreeID resetSampleData formatXMLtext breakPointsscriptSelectionchar 3423 to 3422 bookmarks tempScript prevHandlerresetSampleDatascript:5

-- make sure to switch off edit mode when starting

--

on openStack

send "choose browse tool" to me in 2 ticks

end openStack

-- close all XML trees and tidy display before closing

--

on closeStack

if the short name of this stack = "XMLdemo1" then

send "mouseUp" to btn "CloseAll" of cd 2

save this stack

end if

end closeStack

-- tidy the display when going to a new card

--

on preOpenCard

if the short name of this stack = "XMLdemo1" then

if there is a fld "Info" then set the vScroll of fld "Info" to 0

if there is a fld "XMLtext" then set the vScroll of fld "XMLtext" to 0

end if

end preOpenCard

-- debugging handler for locking & unlocking main text field

--

on commandKeyDown pKey

local tLock

if pKey = "l" then

put the lockText of fld "Info" into tLock

if tLock then

set the lockText of fld "Info" to false

set the traversalOn of fld "Info" to true

else

set the lockText of fld "Info" to true

set the traversalOn of fld "Info" to false

end if

else

pass commandKeyDown

end if

end commandKeyDown

-- function to return true is system is running Mac OS 9 or less

-- this is needed so that the file paths can be translated

--

function isMacOS9

if the platform <> "MacOS" then return false

set the itemDel to "."

if item 1 of the systemVersion < 10 then return true

else return false

end isMacOS9

-- general XML error checker

-- all XML library error messages start with "xmlErr"

--

on checkForError pError

addToTranscript pError

if word 1 of pError contains "xmlErr" then

answer error pError as sheet

exit to top

end if

end checkForError

-- debugging handler to display XML commands & functions

-- and the results of each

--

on addToTranscript pString

local L, tNewString

if pString is empty then put "<empty>" into pString

if pString contains "XML" is false and pString contains "rev" is false then

repeat for each line L in pString

put tab & L & cr after tNewString

end repeat

put tNewString into pString

end if

put pString & cr after fld "XMLtranscript" of stack "XMLtranscript"

set the vScroll of fld "XMLtranscript" of stack "XMLtranscript" to 100000

end addToTranscript

-- handler to clear contents of debugging transcript

--

on clearTranscript

put empty into fld "XMLtranscript" of stack "XMLtranscript"

end clearTranscript

-- display function to add quotes before & after a string

--

function q pString

return quote & pString & quote

end q

-- this is a precautionary routine called whenever one of the demo scripts needs to access the sample data

-- if the sample data is not currently loaded into an XML tree, this will load it, beofre returning the document ID

--

-- this also clears the transcript display and sets the tabStops of the display field for XML data

--

function getTreeID

if fld "DocID" is not a number then

lock screen

send "mouseUp" to btn "Add all the data" of cd "Add"

unlock screen

end if

clearTranscript

set the tabStops of fld "XMLtext" to 25

return fld "DocID"

end getTreeID

-- this handler can be called from any of the info cards

-- it just resets the sample data and displays it

--

on resetSampleData

lock screen

send "mouseUp" to btn "Add all the data" of cd "Add"

if there is a fld "XMLtext" then put formatXMLText(fld "DocID") into fld "XMLtext"

clearTranscript

unlock screen

end resetSampleData

-- custom function for formatting simple XML text data

-- it adds linefeeds and indents where appropriate to make the data more readable

-- It may not get it exactly right and complex XML files may take a while to process,

-- but it should give a better representation than the raw text dump

--

function formatXMLtext pDocID

local tXML, tMaxLines, tNewXML, tLine, tStartTag, tEndTag, tNextLine, tEndLine

local L, x, y

put revXMLText(pDocID) into tXML

replace "><" with ">" & cr & "<" in tXML

replace "</" with "§§" in tXML

replace "<" with cr & "<" in tXML

replace "/>" with "/>" & cr in tXML

replace "§§" with "</" in tXML

replace "&gt;" & cr with cr in tXML -- needed when translating to Mac OS 9

filter tXML with "?*"

-- get rid of any excess white space at start or end of lines

-- lines containing only tabs need to be removed also

repeat for each line L in tXML

if the number of words in L < 1 then next repeat

put word 1 to -1 of L & cr after tNewXML

end repeat

put tNewXML into tXML

put the number of lines in tXML into tMaxLines

repeat with x = 2 to tMaxLines

put line x of tXML into tLine

put word 1 of tLine into tStartTag

if char 2 of tStartTag = "/" then next repeat

if tStartTag contains ">" then

get offset(">", tStartTag)

put char 1 to it-1 of tStartTag into tStartTag

end if

put tStartTag into tEndTag

put "/" after char 1 of tEndTag

if tLine contains tStartTag and tLine contains tEndTag then next repeat

put x + 1 into tNextLine

get lineOffset(tEndTag, tXML, tNextLine)

if it > 0 then

put tNextLine + it - 1 into tEndLine

repeat with y = tNextLine to tEndLine

put tab before line y of tXML

end repeat

end if

end repeat

if last char of tXML = cr then delete last char of tXML

return tXML

end formatXMLtext

Index P`on closeCard hide grp "About" end closeCard on preOpenCard if the platform = "MacOS" then set the icon of btn "About" to 50002 else set the icon of btn "About" to 50001 end if end preOpenCard on openCard if the openStacks contains "XMLtranscript" then send mouseUp to btn "Close" of stack "XMLtranscript" end if end openCard cREVGeometryCacheIDs1085987838942108910859873542171086108036298780110031085987479227108710803632038481005108840448654411051085987009064108510859865993911084108036511534410291080363036263100410900279467605000210803632338701006108180526514510781090027950401500011085987888306109010884047763961107cREVGeometryCachetotal16order  cREVGeneralscriptChecksumIƓrGХҎ3 bookmarks handlerListcloseCard preOpenCard openCard tempScript prevHandler closeCardscriptSelectionchar 210 to 209script|

on closeCard

hide grp "About"

end closeCard

on preOpenCard

if the platform = "MacOS" then

set the icon of btn "About" to 50002

else

set the icon of btn "About" to 50001

end if

end preOpenCard

on openCard

if the openStacks contains "XMLtranscript" then

send mouseUp to btn "Close" of stack "XMLtranscript"

end if

end openCard

6<=>QBRQFLayout Puon preOpenCard send "mouseUp" to btn "CloseAll" put empty into fld "XMLtext" pass preOpenCard end preOpenCard cREVGeometryCacheIDs10884038112041104108036456502810211080364896236102710804583815491061108840401941911021084118662850107910803646844071025108647647005410951080364226389101310803642301131014108036468291210241080364421377101710884038066211103108036445872110181080364398959101610865053926141098108036450637910191080364166495101210803647707101026108036506250910281080364623715102310803643490811015cREVGeometryCachetotal22order  cREVGeneralscriptChecksumM7Uh8NxX bookmarks handlerList preOpenCard tempScript prevHandler preOpenCardscriptSelection char 1 to 0script(

on preOpenCard

send "mouseUp" to btn "CloseAll"

put empty into fld "XMLtext"

pass preOpenCard

end preOpenCard

GWhat PRon preOpenCard put empty into fld "XMLtext" pass preOpenCard end preOpenCard cREVGeometryCacheIDs1088403811204110410803645650281021108036489623610271080458381549106110884040194191102108411866285010791080364684407102510803642263891013108036423011310141085219594175108010803646829121024108036442137710171088403806621110310803644587211018108036439895910161086505392614109810803645063791019108036416649510121080459870221106210803647707101026108036506250910281080364623715102310803643490811015cREVGeometryCachetotal23order  cREVGeneralscriptChecksumt`#heX bookmarks handlerList preOpenCard tempScript prevHandler preOpenCardscriptSelection char 1 to 0script

on preOpenCard

put empty into fld "XMLtext"

pass preOpenCard

end preOpenCard

&8Why Pon preOpenCard put empty into fld "XMLtext" pass preOpenCard end preOpenCard on closeCard put empty into fld "XMLtext" set the tabStops of fld "XMLtext" to 25 end closeCard cREVGeometryCacheIDs10884038112041104108036456502810211080364896236102710804583815491061108840401941911021084118662850107910803646844071025108036422638910131080364230113101410852195941751081108036468291210241080364421377101710884038066211103108036445872110181080364398959101610865053926141098108036450637910191080364166495101210804598702211063108036691320210431080366920483104410803647707101026108036506250910281080364623715102310803643490811015cREVGeometryCachetotal25order  cREVGeneralscriptChecksum{C+lP bookmarks handlerListpreOpenCard closeCard tempScript prevHandler preOpenCardscriptSelection char 1 to 0script

on preOpenCard

put empty into fld "XMLtext"

pass preOpenCard

end preOpenCard

on closeCard

put empty into fld "XMLtext"

set the tabStops of fld "XMLtext" to 25

end closeCard

'9How PRon preOpenCard put empty into fld "XMLtext" pass preOpenCard end preOpenCard cREVGeometryCacheIDs1088403811204110410803645650281021108036489623610271080458381549106110884040194191102108411866285010791080364684407102510803642263891013108036423011310141085219594175108210803646829121024108036442137710171088403806621110310803644587211018108036439895910161086505392614109810803645063791019108036416649510121080459870221106410803647707101026108036506250910281080364623715102310803643490811015cREVGeometryCachetotal23order  cREVGeneralscriptChecksumt`#heX bookmarks handlerList preOpenCard tempScript prevHandler preOpenCardscriptSelection char 1 to 0script

on preOpenCard

put empty into fld "XMLtext"

pass preOpenCard

end preOpenCard

(:Create @cREVGeometryCacheIDs1088403811204110410803645650281021108036489623610271080458381549106110884040194191102108411866285010791080364684407102510803642263891013108036423011310141080364682912102410803644213771017108840380662111031080364458721101810803643989591016108650539261410981080364506379101910803641664951012108045987022110921080366913202104510803647707101026108036506250910281080364623715102310803643490811015cREVGeometryCachetotal23order  cREVGeneralscriptChecksumُ B~ bookmarks handlerList tempScript prevHandler preOpenCardscriptSelection char 1 to 0script

D Add @cREVGeometryCacheIDs108840381120411041080364565028102110803648962361027108045838154910611088404019419110210841186628501079108036468440710251080364226389101310803642301131014108036468291210241080364421377101710884038066211103108036445872110181080364398959101610865053926141098108036450637910191080373087268104710803641664951012108045987022110931080366913202104610803647707101026108036506250910281080364623715102310803643490811015cREVGeometryCachetotal24order E Save @cREVGeometryCacheIDs1088403811204110410803645650281021108036489623610271080458381549106110884040194191102108411866285010791080364684407102510803642263891013108036423011310141086505716640109910803646829121024108036442137710171088403806621110310803644587211018108036439895910161086505392614109810803645063791019108036416649510121080366913202104810803647707101026108036506250910281080364623715102310803643490811015cREVGeometryCachetotal23order  cREVGeneral bookmarks handlerList tempScript prevHandlerscriptSelection char 1 to 0scriptK Open PVon preOpenCard send "mouseUp" to btn "CloseAll" pass preOpenCard end preOpenCard cREVGeometryCacheIDs1080458381549106110803648962361027108036456502810211088403811204110410884040194191102108411866285010791080364684407102510803642263891013108036423011310141080364682912102410803644213771017108840380662111031080364398959101610803644587211018108650539261410981080364506379101910803641664951012108037308726810501080366913202104910803647707101026108036506250910281080364623715102310803643490811015cREVGeometryCachetotal23order  cREVGeneralscriptChecksumXnP- I bookmarks handlerList preOpenCard tempScript prevHandler preOpenCardscriptSelection char 1 to 0script

on preOpenCard

send "mouseUp" to btn "CloseAll"

pass preOpenCard

end preOpenCard

 Find att Pon preOpenCard put empty into fld "XMLtext" pass preOpenCard end preOpenCard on closeCard put empty into fld "XMLtext" set the tabStops of fld "XMLtext" to 25 end closeCard cREVGeometryCacheIDs10884038112041104108036456502810211080364896236102710804583815491061108840401941911021084118662850107910803646844071025108036422638910131080364230113101410803646829121024108036442137710171088403806621110310803644587211018108036439895910161086505392614109810803645063791019108036416649510121080366913202105110803647707101026108036506250910281080364623715102310803643490811015cREVGeometrycachetotal22order  cREVGeneralscriptChecksum{C+lP bookmarks handlerListpreOpenCard closeCard tempScript prevHandler preOpenCardscriptSelection char 1 to 0script

on preOpenCard

put empty into fld "XMLtext"

pass preOpenCard

end preOpenCard

on closeCard

put empty into fld "XMLtext"

set the tabStops of fld "XMLtext" to 25

end closeCard

 Find ele Pon preOpenCard put empty into fld "XMLtext" pass preOpenCard end preOpenCard on closeCard put empty into fld "XMLtext" set the tabStops of fld "XMLtext" to 25 end closeCard cREVGeometryCacheIDs10884038112041104108036456502810211080364896236102710804583815491061108840401941911021084118662850107910803646844071025108036422638910131080364230113101410803646829121024108036442137710171088403806621110310803644587211018108036439895910161086505392614109810803645063791019108036416649510121080366913202105310803647707101026108036506250910281080364623715102310803643490811015cREVGeometrycachetotal22order  cREVGeneralscriptChecksum{C+lP bookmarks handlerListpreOpenCard closeCard tempScript prevHandler preOpenCardscriptSelection char 1 to 0script

on preOpenCard

put empty into fld "XMLtext"

pass preOpenCard

end preOpenCard

on closeCard

put empty into fld "XMLtext"

set the tabStops of fld "XMLtext" to 25

end closeCard

 Edit att Pfon closeCard put empty into fld "XMLtext" set the tabStops of fld "XMLtext" to 25 end closeCard cREVGeometryCacheIDs10884038112041104108036456502810211080364896236102710804583815491061108840401941911021084118662850107910803646844071025108036422638910131080364230113101410803646829121024108036442137710171088403806621110310803644587211018108036439895910161086505392614109810803645063791019108036416649510121080366913202105410803647707101026108036506250910281080364623715102310803643490811015cREVGeometryCachetotal22order  cREVGeneralscriptChecksum6TlJu2cz bookmarks handlerList closeCard tempScript prevHandler closeCardscriptSelection char 1 to 0script4

on closeCard

put empty into fld "XMLtext"

set the tabStops of fld "XMLtext" to 25

end closeCard

 Edit ele Peon closeCard put empty into fld "XMLtext" set the tabStops of fld "XMLtext" to 25 end closeCard cREVGeometryCacheIDs10884038112041104108036456502810211080364896236102710804583815491061108840401941911021084118662850107910803646844071025108036422638910131080364230113101410803646829121024108036442137710171088403806621110310803644587211018108036439895910161086505392614109810803645063791019108036416649510121080366913202105510803647707101026108036506250910281080364623715102310803643490811015cREVGeometryCachetotal22order  cREVGeneralscriptChecksumm. Bdv bookmarks handlerList closeCard tempScript prevHandler closeCardscriptSelection char 1 to 0script,

on closeCard

put empty into fld "XMLtext"

set the tabStops of fld "XMLtext" to 25

end closeCard

 Delete att Pson preOpencard resetSampleData pass preOpenCard end preOpencard on closeCard resetSampleData end closeCard cREVGeometryCacheIDs10884038112041104108036456502810211080364896236102710804583815491061108840401941911021084118662850107910803646844071025108036422638910131080364230113101410803646829121024108036442137710171088403806621110310803644587211018108036439895910161086505392614109810803645063791019108036416649510121080366913202111110803647707101026108036506250910281080364623715102310803643490811015cREVGeometryCachetotal22order  cREVGeneralscriptChecksumU%c/}(s/l9L bookmarks handlerListpreOpencard closeCard tempScript prevHandler closeCardscriptSelection char 1 to 0scriptB

on preOpencard

resetSampleData

pass preOpenCard

end preOpencard

on closeCard

resetSampleData

end closeCard

W. Delete ele Pson preOpencard resetSampleData pass preOpenCard end preOpencard on closeCard resetSampleData end closeCard cREVGeometryCacheIDs1088403811204110410803645650281021108036489623610271080458381549106110884040194191102108411866285010791080364684407102510803642263891013108036423011310141080364682912102410803644213771017108840380662111031080364458721101810803643989591016108650539261410981080364506379101910803730872681069108036416649510121080366913202106810803647707101026108036506250910281080364623715102310803643490811015cREVGeometryCachetotal23order  cREVGeneralscriptChecksumU%c/}(s/l9L bookmarks handlerListpreOpencard closeCardscriptSelection char 1 to 0 prevHandler closeCard tempScriptscript%

on preOpencard

resetSampleData

pass preOpenCard

end preOpencard

on closeCard

resetSampleData

end closeCard

,-/Add att @cREVGeometryCacheIDs1088403811204110410803645650281021108036489623610271080458381549106110884040194191102108411866285010791080364684407102510803642263891013108036423011310141080364682912102410803644213771017108840380662111031080364458721101810803643989591016108650539261410981080364506379101910803730872681075108036416649510121080366913202107410803647707101026108036506250910281080364623715102310803643490811015cREVGeometryCachetotal23order  cREVGeneral bookmarks handlerList tempScript prevHandlerscriptSelection char 1 to 0script230Add ele @cREVGeometryCacheIDs1088403811204110410803645650281021108036489623610271080458381549106110884040194191102108411866285010791080364684407102510803642263891013108036423011310141080364682912102410803644213771017108840380662111031080364458721101810803643989591016108650539261410981080364506379101910803730872681077108036416649510121080366913202107610803647707101026108036506250910281080364623715102310803643490811015cREVGeometryCachetotal23order 45"Tree Pon preOpenCard put empty into fld "XMLtext" pass preOpenCard end preOpenCard on closeCard put empty into fld "XMLtext" end closeCard cREVGeometryCacheIDs108840381120411041080364565028102110803648962361027108045838154910611088404019419110210841186628501079108036468440710251080364226389101310803642301131014108036468291210241080364421377101710884038066211103108036445872110181080364398959101610865053926141098108175122827010661080364506379101910803730872681060108036416649510121080366913202105910803647707101026108036506250910281080364623715102310803643490811015cREVGeometryCachetotal24order  cREVGeneralscriptChecksumSˆH F'd bookmarks handlerListpreOpenCard closeCard tempScript prevHandler preOpenCardscriptSelection char 1 to 0script

on preOpenCard

put empty into fld "XMLtext"

pass preOpenCard

end preOpenCard

on closeCard

put empty into fld "XMLtext"

end closeCard

#$*Command @cREVGeometryCacheIDs108840381120411041080364565028102110803648962361027108045838154910611088404019419110210841186628501079108036468440710251080364226389101310803642301131014108036468291210241080364421377101710884038066211103108036445872110181080364398959101610865053926141098108036450637910191080364166495101210803647707101026108036506250910281080364623715102310803643490811015cREVGeometryCachetotal21order  Label & cREVGeneral revUniqueID 1080362987801 -XML demonstration using Revolution - Part 1: Info 0* cREVGeneral revUniqueID 1080363036263 bookmarks handlerList tempScript prevHandlerscriptSelection char 1 to 0script QRevolution includes an extensive library of handlers for manipulating XML data. This stack shows how to use most of these commands and functions. When working through the tutorial, you can use the "Show transcript" button to display the commands going to the XML library, and the results coming back. Label p%f cREVGeneral revUniqueID 1080363203848 Contents: Index' xon mouseUp local tChoice put the selectedText of me into tChoice if char 1 of tChoice = tab then delete char 1 of tChoice find whole tChoice in fld "Title" find empty end mouseUp @v<22 cREVGeneralscriptChecksum …? revUniqueID 1080363233870 bookmarks handlerListmouseUp tempScript prevHandlermouseUpscriptSelection char 1 to 0script>

on mouseUp

local tChoice

put the selectedText of me into tChoice

if char 1 of tChoice = tab then delete char 1 of tChoice

find whole tChoice in fld "Title"

find empty

end mouseUp

 How this stack is laid out What is XML? Why use XML? How Revolution handles XML? Creating an XML tree  defining the root element adding data Saving the XML as a text file Opening an XML file Finding data in an XML file  finding by attribute  finding by element Editing XML data  editing existing attributes  editing existing elements Deleting XML data  deleting attributes  deleting elements Adding to existing XML data  adding attributes  adding elements Displaying the tree structure Command summary Backgroundi cREVGeneral revUniqueID 1080365062509 HeaderBoxK@< cREVGeneral revUniqueID 1080364166495InfoBoxK@<^ cREVGeneral revUniqueID 1080364226389 bookmarks handlerList tempScript prevHandlerscriptSelection char 1 to 0scriptNavBoxK@< cREVGeneral revUniqueID 1080364230113XMLBoxK@^<^ cREVGeneral bookmarks revUniqueID 1080364349081 handlerListscriptSelection char 1 to 0 prevHandler tempScriptscript Title  $ cREVGeneral revUniqueID 1080364398959  What is XML? F How this stack is laid out  Why use XML?  How Revolution handles XML?  Command summary  0Creating an XML tree: defining the root element  Opening an XML file  Saving the XML as a text file  'Deleting XML data: deleting attributes " Displaying the tree structure 0 -Adding to existing XML data: adding elements / /Adding to existing XML data: adding attributes . %Deleting XML data: deleting elements  ,Editing XML data: editing existing elements  .Editing XML data: editing existing attributes  0Finding data in an XML file: finding by element  2Finding data in an XML file: finding by attribute  "Creating an XML tree: adding data  DocIDLabel  cREVGeneral revUniqueID 1080364421377 Current XML tree ID: DocID 0 cREVGeneral revUniqueID 1080364458721 bookmarks handlerList tempScript prevHandlerscriptSelection char 1 to 0script none XMLtext)`@rP6H cREVGeneral revUniqueID 1080364506379 `Q7)as% Info 7-- handler to assess links and either go to a web page, -- jump to a selected section or display the relevant Transcript documentation -- -- Links to docs tested with Rev 2.2 and with Rev 2.3A3 -- on linkClicked pLink local tVersion, tStackName if pLink contains "http:" then revGoURL pLink else lock screen find whole pLink in fld "Title" if the result <> "Not found" then find empty exit to top end if put revAppVersion() into tVersion get offset(".", tVersion) if it > 0 then put char 1 to it+1 of tVersion into tVersion if tVersion < 2.5 then put "revDocsLanguageReference" into tStackName if there is a cd pLink of stack tStackName then go to cd pLink of stack tStackName else if there is a cd (pLink & " command") of stack tStackName then go to cd (pLink & " command") of stack tStackName else if there is a cd (pLink & " function") of stack tStackName then go to cd (pLink & " function") of stack tStackName else if there is a cd (pLink & " message") of stack tStackName then go to cd (pLink & " message") of stack tStackName else beep end if else go to stack "revdocs" send "mouseUp" to btn "Dictionary" of cd 1 of stack "revdocs" get lineOffset(pLink, fld "List" of cd 1 of stack "revdocs") if it > 0 then select line it of fld "List" of cd 1 of stack "revdocs" send "mouseUp" to fld "List" of cd 1 of stack "revdocs" else beep end if end if end if end linkClicked @P6H cREVGeneralscriptChecksumz]IOz revUniqueID 1080364565028 bookmarks handlerList linkClicked tempScript prevHandler linkClickedscriptSelectionchar 605 to 604script5

-- handler to assess links and either go to a web page,

-- jump to a selected section or display the relevant Transcript documentation

--

-- Links to docs tested with Rev 2.2 and with Rev 2.3A3

--

on linkClicked pLink

local tVersion, tStackName

if pLink contains "http:" then

revGoURL pLink

else

lock screen

find whole pLink in fld "Title"

if the result <> "Not found" then

find empty

exit to top

end if

put revAppVersion() into tVersion

get offset(".", tVersion)

if it > 0 then put char 1 to it+1 of tVersion into tVersion

if tVersion < 2.5 then

put "revDocsLanguageReference" into tStackName

if there is a cd pLink of stack tStackName then

go to cd pLink of stack tStackName

else if there is a cd (pLink & " command") of stack tStackName then

go to cd (pLink & " command") of stack tStackName

else if there is a cd (pLink & " function") of stack tStackName then

go to cd (pLink & " function") of stack tStackName

else if there is a cd (pLink & " message") of stack tStackName then

go to cd (pLink & " message") of stack tStackName

else

beep

end if

else

go to stack "revdocs"

send "mouseUp" to btn "Dictionary" of cd 1 of stack "revdocs"

get lineOffset(pLink, fld "List" of cd 1 of stack "revdocs")

if it > 0 then

select line it of fld "List" of cd 1 of stack "revdocs"

send "mouseUp" to fld "List" of cd 1 of stack "revdocs"

else

beep

end if

end if

end if

end linkClicked

 This is not intended to be a tutorial on XML itself but on how to use Revolution to manipulate XML data, however some short introduction to XML may be necessary. XML stands for eXtensible Markup Language. Like it's relative HTML, XML contains extra information with each chunk of data. In HTML, that extra data is used to tell a browser how to display the text and the choice of tags is strictly limited to the set that browsers can understand. In XML, the extra information is used to tell the reading program what the data is, and is not limited in any way. HFor some further information for those new to XML, try these web sites: )http://www.w3schools.com/xml/default.asp  ( http://www.xmlfiles.com/xml/   =http://www.javaworld.com/javaworld/jw-04-1999/jw-04-xml.html  < *There are a few basic rules for XML data: C1. Each document must have a header line that identifies it as XML B &2. Each document must have a root tag % 53. Each tag must have a starting tag & an ending tag 4 K4. XML tags are case-sensitive e.g. FirstName is not the same as firstname J h5. All tags must be properly nested i.e. a sub-tag must be closed before it's parent tag can be closed. g 06. Attribute values must be enclosed in quotes. / F NEach card in the tutorial section of this stack contains 4 color-coded areas: 31. The yellow area at the top contains the title of the current section. It also shows the ID number of the XML tree being used at the moment, and contains a button to reset the sample data. As the examples expect a certain data tree, this can be useful after any editing to make sure the data is restored. 2. The blue area at the left (this section) contains the information for the section plus any action buttons containing example scripts for you to run and examine. It can contain links to useful web sites, to entries in the Revolution documentation or to other sectiosn in this tutorial. If a link goes to another section of this tutorial, use the Back button to jump back to where you were. More detailed explanations of the parameters required for each function & command are shown in smaller print, perhaps for reading the second time through.  3. The pink area at the right shows the results of any scripts, either as XML or text. It has a button to show or hide the transcript i.e. the detailed log of commands sent to the XML library and the results returned. ZThis is very useful when reading about the parameters needed by each function or command. Y 4. The green area at the bottom contains the navigation buttons (return to index, go to previous section, go to next section and go back), a popup menu allowing you to jump immediately to any section and a utility button to close all XML trees. In normal use it is not necessary to close every XML tree before opening another, but for the purposes of this tutorial, all trees are closed and a new one created for almost every script example. The scripts used in these examples are mainly in the buttons themselves, with a few utilities in the stack script. The card scripts hold a few formatting and preparative handlers that are not relevant to the XML discussions.  Revolution does not allow you to store data as part of a standalone application. This means storing data externally. In most cases, a separate sub-stack is the best storage mechanism, but what if you wanted to share your data with other people not using Revolution or your application? NThen you need a way of saving the data in a platform and application-independent format. One way is to use external databases, but these require you to set up a server and make sure everyone who needs to access the data is online and can connect. An alternative is to use text files. These have the great advantage that they are universal - almost any application can read and import data from text files. Upgrading to new versions of software doesn't make text files suddenly stop working and there is no proprietary format which limits the number of applications which can read the data.   H XML is merely a text file that includes data about the data. For example, supposing you had data showing details about your employees: First name, last name, ID number, room number, phone extension, parking slot number. ?Click the "Text" button to show the data as a plain text file. When you wrote the program that produced the data, you would have known that column 5 showed the phone extension, but after a few years, it isn't clear whether that is extension, room number or parking slot. Now click the "XML" button. Although this takes up a lot more space, it is immediately clear which data is what. You can read it in a text editor, or even in Internet Explorer. These days, RAM and hard disk space are no longer the limitations they used to be, so we can afford to use more space to make our data safer. And having it stored so that any application can read it AND it can be easily understood, is an enormous benefit. This can make a single set of data useable by multiple applications and allows the same data to be processed in multiple ways for different types of output i.e. web pages, printed books, catalogs, PDAs etc. DThe other big plus is that XML is easily extended. Suppose we have our data as shown, but in a year's time we realize that we also need to store email addresses for each employee. In XML, it is a simple matter of inserting a new element into each record, or just into the new records. XML doesn't care if some records are missing the email tag, or if some have more than one email tag. This makes it especially useful for something like a preferences file which may get extra entries as the users select something different to the default or when the original program is updated. For those using Mac OS X, have a look through your system folders. You will see that Apple uses XML to store your preferences, file associations for each application, your iTunes library file, your iPhoto albums and many, many more. eIf you have Revolution 2.5 or higher, take a look at the documentation which is stored in XML files. For Revolution itself, XML provides a standard format that you can use to exchange data between your Revolution applications and other applications. It is also very useful for storing preferences as it allows easy retrieval and editing of named characteristics.  ~Internally, Revolution stores XML data as a "tree". You read XML data into a tree, or you create a tree and then insert data. When a tree is created, Revolution assigns it an ID number. When we make an XML tree during our tests, the ID number will be displayed in the top right corner of this stack. Any commands for dealing with the tree, must use this ID number to tell the Revolution engine which XML tree you are dealing with. In the examples in this stack, no more than one tree is open at a time, but it is quite possible to be operating on multiple trees at the same time. 6Within the tree, you must have a root element that includes all the data. In Revolution terms, this is the "Parent Node". Inside the parent node, you will have other nodes. It there is more than one of a particular node, they will be referred to using array-type numbering. You will see samples of this later. ~When you need to turn the XML data back to text, you use one of the XML library functions to convert the tree into text form. Each tree is stored in memory and will not be saved with your stack unless you convert it to text and save it either in a stack or as a separate file. The XML library contains 32 commands, messages and functions. To see a list, open the Transcript Dictionary and filter using "XML" or jump to the "Command Summary" section of this stack.    mWhen building a standalone which uses the XML library, you must make sure it is included in the application.  5XML library handlers used or discussed in this demo: revAddXMLNode command   revCreateXMLTree function   "revCreateXMLTreeFromFile function  ! revDeleteXMLTree command   revDeleteAllXMLTrees command   revDeleteXMLNode command   revPutIntoXMLNode command   revSetXMLAttribute command   revXMLAttributes function   revXMLChildContents function   revXMLFirstChild function   revXMLMatchingNode function   revXMLNextSibling function   revXMLNodeContents function   revXMLNumberOfChildren function   revXMLPreviousSibling function   revXMLRootNode function   revXMLText function   revXMLTree function   revXMLTrees function   9XML library handlers NOT used or discussed in this demo: revAppendXML command   revEndXMLNode message   revEndXMLTree message   revStartXMLData message   revStartXMLNode message   revStartXMLTree message   revXMLAddDTD command   revXMLAttribute function   revXMLAttributeValues function   revXMLChildNames function   revXMLParent function   revXMLValidateDTD function   QClick on any of the links to see the documentation for that command or function.  OK, this is where we start to use the XML features of Revolution. As mentioned in the previous section, Revolution stores XML data in a tree. So when we want to convert some data to XML, the first thing we need to do is make a tree.  Each XML document must have what is called a "root tag". That is a single tag that includes ALL the data. If you go back to "Why use XML?" and click the "XML" button, you will see that the root tag for our sample data is called "employeeTable". }  } k 8To create a tree, we use the revCreateXMLTree function.    - This takes four parameters:  Q1. The XML data - as we are just starting, the only data so far is our root tag. P 2. parseBadData (true or false) - if this is true then Revolution will try to convert the supplied data to XML even if it is not "well-formed" i.e. even if it is not correct XML. It is set to false so that Revolution will reject any bad data.  3. createTree (true or false) - I can't see why you would ever want this to be false. This example is creating a tree, so createTree must be set to true.  4. sendMessages (true or false) - the XML library includes a set of messages which can be sent while the library is parsing the XML data. At the moment, that is set to false.  In XML, each tag must be part of a pair. The opening tag must be "" and the closing tag must be "". See the next section for details on allowed tag names. gAt the start of our tree, we only have the root tag and no other data, so we will set our XML data to: &The script for creating our table is: (put "" \ ' into tData  %get revCreateXMLTree(tData, false, \ $ true, false)  checkForError it  put it into docID  6All the XML functions return an error message starting with "XMLerr" if they fail. Otherwise, the function returns the newly created tree's ID. The checkForError handler is a general error handler in the stack script. If there is no error, the value returned by the function is stored as our tree's ID number. Then we display the XML text in the field to the right. As the tag is empty, the shorter version is shown, which opens and closes the tag at the same time. mIf you want to see the XML commands used and the results that come back, click the "Show Transcript" button.  There are two ways to read XML data from a file: the first one uses a single function: revCreateXMLTreeFromFile, which reads the file and creates a tree from it in a single step. W  W oC As an alternative, you can read the text file into memory and then use the data it contains to create a tree in the same way that we created the original empty tree, using the revCreateXMLtree command.   In both cases, the function takes 4 parameters exactly as discussed in the section "Creating an XML tree: defining the root element" but with the first parameter for the revCreateXMLTreeFromFile function being a file path instead of text data. T T/ '  1 In Mac OS 9, the revCreateXMLTreeFromFile function needs a Mac-style file path, which can be obtained using the revMacFromUnixPath function.   )G p  Note: these commands will NOT work properly in Classic, so if you are developing on Mac OS X for earier systems, you will need to boot into Classic for complete testing.  nTry the first button "Create from file" but if that gives an error, use the second button "Read then create". You can select the file you saved in the last step, or choose any XML file - there are several sample XML files included in the Revolution application folder as well as the documentation files if you are using Revolution 2.5 or greater. Any formatting applied to the text data in the form of tabs or linefeeds will be ignored by the XML parser, so the text input can be processed in any way that makes it more readable - the XML interpreter will ignore all that.  cOnce the tree has been created, it can easily be converted to text using the revXMLText function. M  M W  This takes up to 2 parameters, with the first one being the ID number of the XML tree to show as text and the second optional parameter being the node to start with. If the second parameter is empty, all nodes are displayed, which is the way it is used in this tutorial.  However the revXMLText function produces rather strange looking XML data as it contains no linefeeds. If you try to show it in a field, you may run into the Revolution line length limitation, so some processing needs to be done first. Click "Convert to text" to see how this looks.   There is an undocumented parameter of this command that does some formatting, but I find that it still puts too much on a single line. EOption/Alt-click the "Convert to text" buttonn to see what it gives. 1If you look in the stack script, you will see a function called formatXMLtext which I have written to display simple XML trees, neatly formatted with indents to show which nodes are inside which. It won't always work for complex XML documents, but it will enable you to display XML documents in a field. If you click "Reset sample data" or "Save XML to file", this function will be used to produce the display on the right, ready for saving. Now you can treat it as you would any text data and save it to a text file using the URL commands. As we will need to open the file later, please click the button below, which will make sure the data has been created fully, and ask you where it should be saved. Once you have saved the file, try opening it using Internet Explorer. It should be displayed with plus & minus buttons for expanding and contracting the nodes.  Short answer: you can't! As far as I can tell, Revolution's XML library does not allow for deletion of an attribute. The closest you can get is emptying an attribute by editing it to "". Long answer: you can! There is an undocumented command for this: revRemoveXMLAttrribute. As this is undocumented, it should not be relied on as it may not appear in later versions, but as of Revolution 2.5RC1, it's still there and still undocumented. revXMLRemoveAttribute is a command and it's three parameters are: the document ID, the node and the name of the attribute to remove.  " The Revolution XML library includes a useful tool for analyzing the structure of your XML data: revXMLTree. The only thing to note is that is does not show attributes, only elements. `  ` jL JMost of the parameters for this function should be quite familiar by now: I )1. The ID number of the tree to display. ( *2. The address of the node to start with. ) g3. A new one - the character to use for indenting to show the depth of each node. Tab works very well. f C4. Whether to include the array-type numbering of each child node. B [5. How far down the tree to go. As before, specifying a depth of -1 means show everything. Z qIf you have added the duplicate phoneExt element on the previous card, you will see that it is shown as phoneExt[2] in it's parent node, because the includeChildCount parameter (#4) is set to true. This enables you to retrieve either value when you need to. (If you haven't, clicking "Reset sample data" on this card will insert an extra phoneExt element in record 1.) The "Show Data" button uses the revXMLText function and my formatXML function to display the XML text as usual. Toggle back & forth between the two displays to see how they fit together.  * 0 Elements can be added using the same syntax as used in the initial XML data creation routines, however those routines covered adding complete records to the root node. It is also possible to add new elements to all or selected nodes. Click "Add new elements" to add an email address element to 3 out of 4 of the current records. Notice how XML does not insist that all records contain the same elements. XML also allows you to have more than one entry for a specific section of data in each record. For example, suppose one of our employees has two phone extensions. Click the "Add duplicate" button, which adds an extra phone extension for one of the records. fPeople familiar with XML may notice the absence of any commands for entering CDATA i.e. data where the characters which are not allowed in XML (like <, >, & etc.) are entered in such a way that the XML parser is instructed to ignore them. Because the Revolution XML commands automatically format any XML data to the correct structure, this is not necessary. ]Both the scripts below use the revAddXMLNode command as detailed in the adding data section.    ,  H S / As a general rule, don't use attributes to store data. Use attributes to store information about the data e.g. ID numbers. All data can be stored in either attributes or in elements, but it is usually better to put data in elements. It makes for much more readable XML data files. However, sometimes you will want to use attributes, especially as Revolution makes it easy to search for records using attributes. In the sample data, I have used an IDnum attribute for that reason. Attributes can be added to any tag, including the root tag. Use the test buttons below to see how you can add a secondID attribute to the employee tag and then to see how to add a hasWindow attribute to the roomNum tag. For XML to be "well-formed" all attribute values must be contained in quotes. Revolution's XML library handles this, so in my examples, I was able to set the attribute to an unquoted number or literal and the resulting XML text shows it enclosed in quotes. The first example button adds a "secondID" attribute to one of the records. The other one adds an attribute to one of the lower level nodes. It inserts a "hasWindow" attribute into one of the "roomNum" elements. QBoth use the revSetXMLAttribute command as discussed in the adding data section.     < G . As with editing, the first step to deletion is finding the node to delete. This can be a sub-node e.g. Bill Gates' parking slot, or it could be a complete data record e.g. Linus Torvald.  Once the node has been found, the revDeleteXMLNode command will delete it from the tree. Remember that these edits and deletions only affect the tree stored in RAM. The data is not automatically saved, so no changes are complete until the data is saved externally. "  " 2 dThis command needs 2 parameters: the XML tree ID (as always) and the address of the node to delete. c XML does not insist on having an empty node if there is no data. It is quite OK to have a node missing as is the case here after deleting a sub-node which removes someone's parking space. Note: deleting a non-existent node does not cause an error (try deleting node 99 for example), the revDeleteXMLNode command still returns empty. c  c s  As with editing an attribute, first you need to find the node to edit. Then you use revPutIntoXMLNode just as when adding data initially. T  T e  s ~ This example picks a random record using the element number rather than the IDnum, since the IDnums may have been edited while doing the previous tests. vOnce the correct record has been found, it is displayed using the revXMLAttributes and revXMLChildContents functions. B  B R  W j The only new command here is revXMLAttributes which displays a list of all the attributes for a specified node. The first two parameters are the tree ID and the address of the node, while the remaining two set the display format for the returned text. The button below uses two tabs to separate the attribute name from it's value and a return (cr) to separate different attributes (although there is only one in this case).   -{ @Then the edits are applied, before the data is displayed again. KIn this example, someone is being randomly re-assigned a new parking slot.  Editing an existing attribute is a two step process. Firstly, you have to find the node of the attribute to edit, then you have to change the current data in the specified attribute in that node. Finding the node can be done using either of the two techniques discussed in the previous two cards: finding by attribute or finding by element. e  e y  }  3Or if you already know which node you would like to edit, you can specify that directly instead of searching. As we have seen earlier, nodes are identified using array-type numbering, with "/" used as the divider between nodes at different levels, so the third record in our test data is referred to using:  /employeeTable/employee[3] &and the last name for that record is: ( /employeeTable/employee[3]/lastName Once the node has been identified, the attribute is set using the revSetXMLAttribute exactly as used when adding data after first creating the tree. B  B T  j u ;The button below will edit one of the ID numbers randomly.  Unlike searching by attribute, searching for a particular element requires stepping through the nodes and checking each individually (unless there is some function that I have missed). Here's one way to do it: N- check how many records there are using the revXMLNumberOfChildren function. -  - C =- go to the first record using the revXMLFirstChild function #  # 3 T- set up a loop to test the contents of a particular node using revXMLNodeContents. @  @ R P- each time through the loop, use revXMLNextSibling to step to the next record. "  " 3 - once the correct record has been identified, revXMLChildContents shows all it's data or revXMLNodeContents can be used to extract one segment of the data. /  / B  Z l0 UNote that the revXMLNextSibling function takes the address of the current node as it's parameter. Each time through the loop, you have to get the address of it's node and use that as the address to go to the next node. revXMLPreviousSibling works in exactly the same way only stepping backwards through the list, but I haven't used it here.       d The parameters used by these handlers should be getting familiar by now. revXMLNumberOfChildren takes 3 or 4 parameters: tree ID, starting node, child node name and optionally the depth to search. In this example, the starting node is the parent or root node, the child node is left blank to indicate that all nodes are to be searched and the depth is set to 0 (zero) indicating that the function is to count the children of the root node only and none of their children. I I _x  The revXMLFirstChild function only requires 2 parameters: the tree ID and the address of the node to start scanning, here the root node.   t  xThe revXMLNodeContents and revXMLChildContents functions are discussed in the previous section: "finding by attribute".     .3 a u  revXMLNextSibling requires the tree ID and the address of the current node, initially as returned by revXMLFirstChild and then the address returned by each subsequent call to revXMLNextSibling.  T e u:   The "Find by element" button below chooses a random last name and finds all the data associated with that last name, picking out the phone extension element.  Using the Revolution XML library, the easiest way to find a record is to search by attribute. The function for searching by attributes is called revXMLMatchingNode.    "This function takes 6 parameters: ! "1. The ID number of the XML tree. ! 2. The node where you want to start the search - to search the entire tree, use the parent node as returned by the revXMLRootNode function. s s  $3. The name of the child node to search - here it is left blank so as to search all nodes, but since the IDnum attribute is only in the employee tags, "employee" could also be used for this parameter. For a more complex XML tree, specifying the child node to search would increase the speed. # @4. The name of the attribute to look for - in this case "IDnum" ? H5. The value to search for - in this example, any number between 1 & 4. G 6. The depth to search, -1 means search down through all the layers, but as the IDnum is in the top layer of the tree, 1 could be used instead, to search only the direct children of the root node.  This function returns a node address and then using the revXMLChildContents function, you can retrieve the entire contents of that node. 8  8 K= "The parameters for this function are similar to those for revXMLMatchingNode: 1 - tree ID, 2 - starting node and 6 - search depth, but parameters 3 & 4 show how the resulting text should be formatted: tab & cr/return work well if the data is to displayed in a field. Parameter 5 must be either true or false to indicate whether the result shows the array-type index numbers for each displayed node. If there is only one of each node this is not important, but with more complex XML documents, showing these numbers will make it easier to follow. : : L  iTo find a particular piece of data, use the revXMLNodeContents function, but enter a specific node name. ,  , >*  It only requires the tree's ID number and the node address - in this case, the result of revXMLMatchingNode with the name of the required tag added on to it. Y Y k2 4Click the "Find by Attribute" button below and enter a number between 1 & 4. The field on the right will display the address of the matching node and then all the data for that node. Assuming we were looking for a full name, the firstName & lastName elements are extracted and displayed in an answer dialog.  Now the tree has been created and hopefully you can see an ID number in the ID field at the top right. if you can't, it doesn't matter as the tree will be re-created for you when you click either of the "Add data" buttons below. To add some data, we are going to use revSetXMLAttribute and revAddXMLNode, so I guess now would be a good time to explain about nodes (or elements) and attributes. &  & 8  = JZ LIf you jump back again to the example in "Why use XML?" and click "XML", you will see that the IDnum is stored differently to the other data. Each employee's data is contained in an tag, so you can see that the tag is part of each employee's record. But the IDnum doesn't seem to have it's own tag, it is just stuck inside the opening tag label. This is because it is an attribute, rather than a normal XML element. Mostly, you will store data in elements/nodes, but sometimes it is convenient to use attributes to allow you to find records more easily. *  * 6 GWe can see from the example, that each employee record is enclosed in an tag, with an IDnum attribute. Then there are the five other tags, to show the rest of the data. Unlike tab-delimited data, XML doesn't care whether all the data is filled in, but in our example, all the records have the same segments of data. pAs a general rule, store all data in elements and store data about the data (say an ID number) as an attribute. .For each record, we need to do the following: P1. add the node and record the allocated name for this new sub-node. ,2. add the IDnum attribute to the new node. *3. add the five elements to the new node. }Check the script of the "Add one set of data" button underneath for how to do this which uses two different revXML commands: revAddXMLNode adds the employee node and it's elements (steps 1 & 3) and revSetXMLAttribute adds the IDnum attribute to the employee node.  <  I [/ 6The parameters for both these commands are the same: 5 1. the XML document or tree ID,  Y2. the address of the node or sub-node where the new element or attribute is being added X ,3. the name of the new element or attribute + =4. the data to be inserted in that new element or attribute. < When you have checked the script in that button, click the next button: "Add all the data" to create the entire data set as shown in the previous example. It uses the same XML commands but from inside a custom record-creation handler. -XML elements must follow these naming rules: ;- names can contain letters, numbers, and other characters : >- names must not start with a number or punctuation character = ,- names must not start with the letters xml + - names cannot contain spaces  - avoid using colon (:), period (.) or dash (-). Colon is reserved and the other two can cause problems when read by other applications.   8QFIndexC7@-- go to the Index card -- on mouseUp go to cd 1 end mouseUp * ? cREVGeneralscriptChecksum<*FNZ󚭦w revUniqueID 1080364623715 bookmarks handlerListmouseUp tempScript prevHandlermouseUpscriptSelection char 1 to 0script

-- go to the Index card

--

on mouseUp

go to cd 1

end mouseUp

PrevC7"on mouseUp go prev end mouseUp K* @ cREVGeneralscriptChecksum?N~]=d~ revUniqueID 1080364682912 bookmarks handlerListmouseUp tempScript prevHandlermouseUpscriptSelection char 1 to 0scripto

on mouseUp

go prev

end mouseUp

NextC7"on mouseUp go next end mouseUp }* A cREVGeneralscriptChecksum}Ou$n/ revUniqueID 1080364684407 bookmarks handlerListmouseUp tempScript prevHandlermouseUpscriptSelection char 1 to 0scripto

on mouseUp

go next

end mouseUp

JBackC7Qon mouseUp lock messages -- to stop scroll resetting go recent end mouseUp *  cREVGeneralscriptChecksum%,o\a7 bookmarks revUniqueID 1086505392614 handlerListmouseUpscriptSelection char 30 to 29 prevHandlermouseUp tempScriptscript

on mouseUp

lock messages -- to stop scroll resetting

go recent

end mouseUp

NavMenu }-- jump to a selected section -- the find empty line removes the box around the found text -- on menuPick pChoice lock screen set the itemdel to "|" if pChoice contains "|" then put item 2 of pChoice into pChoice find whole pChoice in fld "Title" find empty end menuPick Jump to a sectionHow this stack is laid out What is XML? Why use XML? How Revolution handles XML? Creating an XML tree defining the root element adding data Saving the XML as a text file Opening an XML file Finding data in an XML file finding by attribute finding by element Editing XML data editing existing attributes editing existing elements Deleting XML data deleting attributes deleting elements Adding to existing XML data adding attributes adding elements Displaying the tree structure Command summary cREVGeneral scriptChecksumѝE*8i[[ breakPoints handlerListmenuPickscriptSelection char 1 to 0 revUniqueID 1080364770710 bookmarks tempScript prevHandlermenuPickscript

-- jump to a selected section

-- the find empty line removes the box around the found text

--

on menuPick pChoice

lock screen

set the itemdel to "|"

if pChoice contains "|" then put item 2 of pChoice into pChoice

find whole pChoice in fld "Title"

find empty

end menuPick

 CloseAlle-- close any open XML trees -- this script actually uses two methods for demonstration purposes -- on mouseUp local tDocID -- empty the transcript window so each time the trees are closed, we start with a fresh display clearTranscript -- this deletes just the current tree as recorded in the DocID field put fld "DocID" of cd 2 into tDocID if tDocID is a number then addToTranscript "revDeleteXMLTree " & tDocID revDeleteXMLTree tDocID addToTranscript the result end if -- this checks to see if there are any open trees and if so, closes then all addToTranscript "revXMLTrees()" addToTranscript revXMLTrees() if revXMLTrees() is not empty then addToTranscript "revDeleteAllXMLTrees" revDeleteAllXMLTrees addToTranscript the result end if -- tidy the display put "none" into fld "DocID" of cd 2 put empty into fld "XMLtext" of cd 2 clearTranscript end mouseUp $Close all XML trees cREVGeneralscriptChecksum*iи revUniqueID 1080364896236 bookmarks handlerListmouseUp tempScript prevHandlermouseUpscriptSelectionchar 922 to 921script

-- close any open XML trees

-- this script actually uses two methods for demonstration purposes

--

on mouseUp

local tDocID

-- empty the transcript window so each time the trees are closed, we start with a fresh display

clearTranscript

-- this deletes just the current tree as recorded in the DocID field

put fld "DocID" of cd 2 into tDocID

if tDocID is a number then

addToTranscript "revDeleteXMLTree " & tDocID

revDeleteXMLTree tDocID

addToTranscript the result

end if

-- this checks to see if there are any open trees and if so, closes then all

addToTranscript "revXMLTrees()"

addToTranscript revXMLTrees()

if revXMLTrees() is not empty then

addToTranscript "revDeleteAllXMLTrees"

revDeleteAllXMLTrees

addToTranscript the result

end if

-- tidy the display

put "none" into fld "DocID" of cd 2

put empty into fld "XMLtext" of cd 2

clearTranscript

end mouseUp

%Reset sample dataE-- This closes any existing XML trees and re-creates a new tree with the sample data. -- The handler for this is in the stack script -- on mouseUp resetSampleData end mouseUp  cREVGeneralscriptChecksum%4fAA' bookmarks revUniqueID 1080458381549 handlerListmouseUpscriptSelection char 1 to 0 prevHandlermouseUp tempScriptscriptN

-- This closes any existing XML trees and re-creates a new tree with the sample data.

-- The handler for this is in the stack script

--

on mouseUp

resetSampleData

end mouseUp

7 Transcripteon mouseUp if the label of me = "Hide transcript" then save stack "XMLtranscript" close stack "XMLtranscript" set the label of me to "Show transcript" else if the hilitedButtonName of grp "transcriptPlace" = "at bottom" then set the height of stack "XMLtranscript" to 80 set the width of stack "XMLtranscript" to the width of this stack - 20 drawer stack "XMLtranscript" at bottom set the label of me to "Hide transcript" else set the height of stack "XMLtranscript" to the height of this stack - 20 set the width of stack "XMLtranscript" to 212 drawer stack "XMLtranscript" at right set the label of me to "Hide transcript" end if end mouseUp rShow transcript cREVGeneralscriptChecksum(:cNc@:Rt bookmarks revUniqueID 1084118662850 handlerListmouseUpscriptSelectionchar 170 to 169 prevHandlermouseUp tempScriptscript

on mouseUp

if the label of me = "Hide transcript" then

save stack "XMLtranscript"

close stack "XMLtranscript"

set the label of me to "Show transcript"

else if the hilitedButtonName of grp "transcriptPlace" = "at bottom" then

set the height of stack "XMLtranscript" to 80

set the width of stack "XMLtranscript" to the width of this stack - 20

drawer stack "XMLtranscript" at bottom

set the label of me to "Hide transcript"

else

set the height of stack "XMLtranscript" to the height of this stack - 20

set the width of stack "XMLtranscript" to 212

drawer stack "XMLtranscript" at right

set the label of me to "Hide transcript"

end if

end mouseUp

NtranscriptPlaceion mouseUp if the label of btn "Transcript" = "Hide transcript" then send mouseUp to btn "Transcript" send mouseUp to btn "Transcript" end if end mouseUp TZ3 cREVGeneralscriptChecksum}?n{e_mǘ{7, revUniqueID 1088404019419 bookmarks handlerListmouseUp tempScript prevHandlermouseUpscriptSelection char 73 to 72script7

on mouseUp

if the label of btn "Transcript" = "Hide transcript" then

send mouseUp to btn "Transcript"

send mouseUp to btn "Transcript"

end if

end mouseUp

O at right`EXR cREVGeneral revUniqueID 1088403806621 P at bottom`EXR cREVGeneral revUniqueID 1088403811204  Create cardsEw-- construction utility: makes a card for each entry in the index field -- on mouseUp local tList, newList, tExtras, lastLine, L put fld "Index" into tList put empty into newList put empty into tExtras put empty into lastLine repeat for each line L in tList if char 1 of L <> tab then put L into lastLine put L & cr after newList else put lastLine & ": " & char 2 to -1 of L & cr after newList put lastLine & cr after tExtras end if end repeat delete last char of newList repeat for each line L in tExtras filter newList without L end repeat go to card 2 repeat for each line L in newList if fld "Title" is not empty then create card put L into fld "Title" end repeat end mouseUp b R cREVGeneralscriptChecksum'ہ? revUniqueID 1080365115344 bookmarks handlerListmouseUp tempScript prevHandlermouseUpscriptSelection char 1 to 0script0

-- construction utility: makes a card for each entry in the index field

--

on mouseUp

local tList, newList, tExtras, lastLine, L

put fld "Index" into tList

put empty into newList

put empty into tExtras

put empty into lastLine

repeat for each line L in tList

if char 1 of L <> tab then

put L into lastLine

put L & cr after newList

else

put lastLine & ": " & char 2 to -1 of L & cr after newList

put lastLine & cr after tExtras

end if

end repeat

delete last char of newList

repeat for each line L in tExtras

filter newList without L

end repeat

go to card 2

repeat for each line L in newList

if fld "Title" is not empty then create card

put L into fld "Title"

end repeat

end mouseUp

TextE-- show the default set of data as tab-delimited text -- on mouseUp local tData put "Steve/Jobs/1/001/345/100" & cr into tData put "Bill/Gates/2/284/666/987" & cr after tData put "Linus/Torvald/3/43/479/123" & cr after tData put "Kevin/Miller/4/100/421/987" & cr after tData replace "/" with tab in tData put empty into fld "XMLtext" set the tabStops of fld "XMLtext" to "60,120,160" put tData into fld "XMLtext" end mouseUp  cREVGeneralscriptChecksum.")y revUniqueID 1080366913202 bookmarks handlerListmouseUp tempScript prevHandlermouseUpscriptSelection char 1 to 0scriptN

-- show the default set of data as tab-delimited text

--

on mouseUp

local tData

put "Steve/Jobs/1/001/345/100" & cr into tData

put "Bill/Gates/2/284/666/987" & cr after tData

put "Linus/Torvald/3/43/479/123" & cr after tData

put "Kevin/Miller/4/100/421/987" & cr after tData

replace "/" with tab in tData

put empty into fld "XMLtext"

set the tabStops of fld "XMLtext" to "60,120,160"

put tData into fld "XMLtext"

end mouseUp

XMLER-- show the default set of data as XML -- for convenience, it is stored in a custom property of this stack -- but the scripts that created it will be demonstrated later in this stack -- on mouseUp put empty into fld "XMLtext" set the tabStops of fld "XMLtext" to 25 put the cDefaultXML of this stack into fld "XMLtext" end mouseUp  cREVGeneralscriptChecksumKN revUniqueID 1080366920483 bookmarks handlerListmouseUp tempScript prevHandlermouseUpscriptSelection char 1 to 0script

-- show the default set of data as XML

-- for convenience, it is stored in a custom property of this stack

-- but the scripts that created it will be demonstrated later in this stack

--

on mouseUp

put empty into fld "XMLtext"

set the tabStops of fld "XMLtext" to 25

put the cDefaultXML of this stack into fld "XMLtext"

end mouseUp

 Create treeE-- create a new empty XML tree in memory -- on mouseUp local tData, tDocID -- set the root tag to "employeeTable" and format it as a starting tag & ending tag put "" into tData -- create the tree using the root tag data -- parseBadData is set to false so incorrect data will be rejected -- createTree is true and sendMessages is false addToTranscript "revCreateXMLTree(" & q(tData) & ", false, true, false)" get revCreateXMLTree(tData, false, true, false) -- check to see if an error message returned -- all XML library errors start with "xmlErr" -- the checkForError handler is in the stack script and will exit to top if there is an error checkForError it -- store the newly created tree's document ID put it into tDocID put tDocID into fld "DocID" -- show the text version of the new tree put formatXMLtext(tDocID) into fld "XMLtext" end mouseUp 6 cREVGeneralscriptChecksum?6c_ 7ù revUniqueID 1080366913202 bookmarks handlerListmouseUp tempScript prevHandlermouseUpscriptSelectionchar 931 to 930script

-- create a new empty XML tree in memory

--

on mouseUp

local tData, tDocID

-- set the root tag to "employeeTable" and format it as a starting tag & ending tag

put "<employeeTable></employeeTable>" into tData

-- create the tree using the root tag data

-- parseBadData is set to false so incorrect data will be rejected

-- createTree is true and sendMessages is false

addToTranscript "revCreateXMLTree(" & q(tData) & ", false, true, false)"

get revCreateXMLTree(tData, false, true, false)

-- check to see if an error message returned

-- all XML library errors start with "xmlErr"

-- the checkForError handler is in the stack script and will exit to top if there is an error

checkForError it

-- store the newly created tree's document ID

put it into tDocID

put tDocID into fld "DocID"

-- show the text version of the new tree

put formatXMLtext(tDocID) into fld "XMLtext"

end mouseUp

Add one set of dataEon mouseUp local tDocID, tParentNode, tSubNode -- tidy up any old trees first & re-create the test tree send "mouseUp" to btn "CloseAll" send "mouseUp" to btn "Create tree" of card "Create" -- get the document ID for the current XML tree put fld "DocID" into tDocID -- specify the root node for the XML tree put "/employeeTable" into tParentNode -- add the parent element for the new data record and check for error -- the checkForError handler is in the stack script and exits to top -- if any XML error is encountered addToTranscript "revAddXMLNode " & tDocID & ", " & q(tParentNode) & ", " & \ q("employee") & ", " & q() revAddXMLNode tDocID, tParentNode, "employee", "" put the result into tSubNode checkForError tSubNode -- tell the user if the nes data record was added OK answer information "Sub-node created:" & cr & tSubNode as sheet -- add the IDnum attribute to the newly created data record addToTranscript "revSetXMLAttribute " & tDocID & ", " & q(tSubNode) & ", " & \ q("IDnum") & ", " & q(1) revSetXMLAttribute tDocID, tSubNode, "IDnum", "1" checkForError the result -- add the remaining data elements, checking for error after each addition addToTranscript "revAddXMLNode " & tDocID & ", " & q(tSubNode) & ", " & q("firstName") & ", " & q("Steve") revAddXMLNode tDocID, tSubNode, "firstName", "Steve" checkForError the result addToTranscript "revAddXMLNode " & tDocID & ", " & q(tSubNode) & ", " & q("lastName") & ", " & q("Jobs") revAddXMLNode tDocID, tSubNode, "lastName", "Jobs" checkForError the result addToTranscript "revAddXMLNode " & tDocID & ", " & q(tSubNode) & ", " & q("roomNum") & ", " & q("001") revAddXMLNode tDocID, tSubNode, "roomNum", "001" checkForError the result addToTranscript "revAddXMLNode " & tDocID & ", " & q(tSubNode) & ", " & q("phoneExt") & ", " & q("345") revAddXMLNode tDocID, tSubNode, "phoneExt", "345" checkForError the result addToTranscript "revAddXMLNode " & tDocID & ", " & q(tSubNode) & ", " & q("parkingSlot") & ", " & q("100") revAddXMLNode tDocID, tSubNode, "parkingSlot", 100 checkForError the result -- format & display the text version of the new XML document put formatXMLtext(tDocID) into fld "XMLtext" end mouseUp  cREVGeneral scriptChecksum{OSRΉP5p handlerListmouseUp breakPointsscriptSelectionchar 2295 to 2294 revUniqueID 1080366913202 bookmarks tempScript prevHandlermouseUpscript

on mouseUp

local tDocID, tParentNode, tSubNode

-- tidy up any old trees first & re-create the test tree

send "mouseUp" to btn "CloseAll"

send "mouseUp" to btn "Create tree" of card "Create"

-- get the document ID for the current XML tree

put fld "DocID" into tDocID

-- specify the root node for the XML tree

put "/employeeTable" into tParentNode

-- add the parent element for the new data record and check for error

-- the checkForError handler is in the stack script and exits to top

-- if any XML error is encountered

addToTranscript "revAddXMLNode " & tDocID & ", " & q(tParentNode) & ", " & \

q("employee") & ", " & q()

revAddXMLNode tDocID, tParentNode, "employee", ""

put the result into tSubNode

checkForError tSubNode

-- tell the user if the nes data record was added OK

answer information "Sub-node created:" & cr & tSubNode as sheet

-- add the IDnum attribute to the newly created data record

addToTranscript "revSetXMLAttribute " & tDocID & ", " & q(tSubNode) & ", " & \

q("IDnum") & ", " & q(1)

revSetXMLAttribute tDocID, tSubNode, "IDnum", "1"

checkForError the result

-- add the remaining data elements, checking for error after each addition

addToTranscript "revAddXMLNode " & tDocID & ", " & q(tSubNode) & ", " & q("firstName") & ", " & q("Steve")

revAddXMLNode tDocID, tSubNode, "firstName", "Steve"

checkForError the result

addToTranscript "revAddXMLNode " & tDocID & ", " & q(tSubNode) & ", " & q("lastName") & ", " & q("Jobs")

revAddXMLNode tDocID, tSubNode, "lastName", "Jobs"

checkForError the result

addToTranscript "revAddXMLNode " & tDocID & ", " & q(tSubNode) & ", " & q("roomNum") & ", " & q("001")

revAddXMLNode tDocID, tSubNode, "roomNum", "001"

checkForError the result

addToTranscript "revAddXMLNode " & tDocID & ", " & q(tSubNode) & ", " & q("phoneExt") & ", " & q("345")

revAddXMLNode tDocID, tSubNode, "phoneExt", "345"

checkForError the result

addToTranscript "revAddXMLNode " & tDocID & ", " & q(tSubNode) & ", " & q("parkingSlot") & ", " & q("100")

revAddXMLNode tDocID, tSubNode, "parkingSlot", 100

checkForError the result

-- format & display the text version of the new XML document

put formatXMLtext(tDocID) into fld "XMLtext"

end mouseUp

Add all the dataE on mouseUp local tDocID, tParentNode -- tidy up any old trees first & re-create the test tree send "mouseUp" to btn "CloseAll" send "mouseUp" to btn "Create tree" of card "Create" -- get the document ID for the current XML tree put fld "DocID" into tDocID -- specify the root node for the XML tree put "/employeeTable" into tParentNode -- call a sub routine to add each new record addNewEntry tDocID, tParentNode, "1", "Steve", "Jobs", "001", "345", "100" addNewEntry tDocID, tParentNode, "2", "Bill", "Gates", "284", "666", "987" addNewEntry tDocID, tParentNode, "3", "Linus", "Torvald", "43", "479", "123" addNewEntry tDocID, tParentNode, "4", "Kevin", "Miller", "100", "421", "987" -- format & display the text version of the new XML document put formatXMLtext(tDocID) into fld "XMLtext" end mouseUp -- sub routine to add a complete record: ID attribute and the data elements -- the checkForError handler is in the stack script and exits to top -- if any XML error is encountered -- on addNewEntry pDocID, pParent, pIDnum, pFirst, pLast, pRoom, pExt, pPark local tSubNode -- add the parent element for the new data record and check for error addToTranscript "revAddXMLNode " & pDocID & ", " & q(pParent) & ", " & q("employee") & ", " & q() revAddXMLNode pDocID, pParent, "employee", "" put the result into tSubNode checkForError tSubNode -- add the IDnum attribute to the newly created data record addToTranscript "revSetXMLAttribute " & pDocID & ", " & q(tSubNode) & ", " & q("IDnum") & ", " & q(pIDnum) revSetXMLAttribute pDocID, tSubNode, "IDnum", pIDnum checkForError the result -- add the remaining data elements, checking for error after each addition addToTranscript "revAddXMLNode " & pDocID & ", " & q(tSubNode) & ", " & q("firstName") & ", " & q(pFirst) revAddXMLNode pDocID, tSubNode, "firstName", pFirst checkForError the result addToTranscript "revAddXMLNode " & pDocID & ", " & q(tSubNode) & ", " & q("lastName") & ", " & q(pLast) revAddXMLNode pDocID, tSubNode, "lastName", pLast checkForError the result addToTranscript "revAddXMLNode " & pDocID & ", " & q(tSubNode) & ", " & q("roomNum") & ", " & q(pRoom) revAddXMLNode pDocID, tSubNode, "roomNum", pRoom checkForError the result addToTranscript "revAddXMLNode " & pDocID & ", " & q(tSubNode) & ", " & q("phoneExt") & ", " & q(pExt) revAddXMLNode pDocID, tSubNode, "phoneExt", pExt checkForError the result addToTranscript "revAddXMLNode " & pDocID & ", " & q(tSubNode) & ", " & q("parkingSlot") & ", " & q(pPark) revAddXMLNode pDocID, tSubNode, "parkingSlot", pPark checkForError the result end addNewEntry  cREVGeneral scriptChecksumT?+o!!P breakPoints handlerListmouseUp addNewEntryscriptSelectionchar 1681 to 1680 bookmarks revUniqueID 1080373087268 prevHandlermouseUp tempScriptscript

on mouseUp

local tDocID, tParentNode

-- tidy up any old trees first & re-create the test tree

send "mouseUp" to btn "CloseAll"

send "mouseUp" to btn "Create tree" of card "Create"

-- get the document ID for the current XML tree

put fld "DocID" into tDocID

-- specify the root node for the XML tree

put "/employeeTable" into tParentNode

-- call a sub routine to add each new record

addNewEntry tDocID, tParentNode, "1", "Steve", "Jobs", "001", "345", "100"

addNewEntry tDocID, tParentNode, "2", "Bill", "Gates", "284", "666", "987"

addNewEntry tDocID, tParentNode, "3", "Linus", "Torvald", "43", "479", "123"

addNewEntry tDocID, tParentNode, "4", "Kevin", "Miller", "100", "421", "987"

-- format & display the text version of the new XML document

put formatXMLtext(tDocID) into fld "XMLtext"

end mouseUp

-- sub routine to add a complete record: ID attribute and the data elements

-- the checkForError handler is in the stack script and exits to top

-- if any XML error is encountered

--

on addNewEntry pDocID, pParent, pIDnum, pFirst, pLast, pRoom, pExt, pPark

local tSubNode

-- add the parent element for the new data record and check for error

addToTranscript "revAddXMLNode " & pDocID & ", " & q(pParent) & ", " & q("employee") & ", " & q()

revAddXMLNode pDocID, pParent, "employee", ""

put the result into tSubNode

checkForError tSubNode

-- add the IDnum attribute to the newly created data record

addToTranscript "revSetXMLAttribute " & pDocID & ", " & q(tSubNode) & ", " & q("IDnum") & ", " & q(pIDnum)

revSetXMLAttribute pDocID, tSubNode, "IDnum", pIDnum

checkForError the result

-- add the remaining data elements, checking for error after each addition

addToTranscript "revAddXMLNode " & pDocID & ", " & q(tSubNode) & ", " & q("firstName") & ", " & q(pFirst)

revAddXMLNode pDocID, tSubNode, "firstName", pFirst

checkForError the result

addToTranscript "revAddXMLNode " & pDocID & ", " & q(tSubNode) & ", " & q("lastName") & ", " & q(pLast)

revAddXMLNode pDocID, tSubNode, "lastName", pLast

checkForError the result

addToTranscript "revAddXMLNode " & pDocID & ", " & q(tSubNode) & ", " & q("roomNum") & ", " & q(pRoom)

revAddXMLNode pDocID, tSubNode, "roomNum", pRoom

checkForError the result

addToTranscript "revAddXMLNode " & pDocID & ", " & q(tSubNode) & ", " & q("phoneExt") & ", " & q(pExt)

revAddXMLNode pDocID, tSubNode, "phoneExt", pExt

checkForError the result

addToTranscript "revAddXMLNode " & pDocID & ", " & q(tSubNode) & ", " & q("parkingSlot") & ", " & q(pPark)

revAddXMLNode pDocID, tSubNode, "parkingSlot", pPark

checkForError the result

end addNewEntry

Save XML to fileE7-- this saves the currently created XML tree to disk -- on mouseUp local tFileName -- re-create the sample data before saving, just to make sure it is the correct data -- this puts the formatted text version of the tree into field "XMLtext" resetSampleData ask file "Save XML data as:" with "Sample.xml" as sheet put it into tFileName set the fileType to "" if tFilename is empty then answer warning "You will need an XML file for the next example!" as sheet else put fld "XMLtext" into URL ("file:" & tFileName) end if end mouseUp  cREVGeneralscriptChecksumPdٗWh~e revUniqueID 1080366913202 bookmarks handlerListmouseUp tempScript prevHandlermouseUpscriptSelectionchar 378 to 377scriptI

-- this saves the currently created XML tree to disk

--

on mouseUp

local tFileName

-- re-create the sample data before saving, just to make sure it is the correct data

-- this puts the formatted text version of the tree into field "XMLtext"

resetSampleData

ask file "Save XML data as:" with "Sample.xml" as sheet

put it into tFileName

set the fileType to ""

if tFilename is empty then

answer warning "You will need an XML file for the next example!" as sheet

else

put fld "XMLtext" into URL ("file:" & tFileName)

end if

end mouseUp

Create from fileEhon mouseUp local tFileName, tDocID -- tidy up any old trees first send "mouseUp" to btn "CloseAll" answer file "Select XML file" as sheet put it into tFileName if tFileName is empty then exit to top if isMacOS9() then put revMacFromUnixPath(tFileName) into tFileName -- read the file data and parse it into an XML tree in a single step -- this may not work with Mac OS 9 -- parseBadData is set to false so incorrect data will be rejected -- createTree is true and sendMessages is false addToTranscript "revCreateXMLTreeFromFile(" & q(tFileName) & " ,false, true, false)" put revCreateXMLTreeFromFile(tFileName, false, true, false) into tDocID checkForError tDocID put tDocID into fld "DocID" -- format & display the text version of the newly loaded XML document put formatXMLtext(tDocID) into fld "XMLtext" end mouseUp  cREVGeneral scriptChecksumS*)P< ip handlerListmouseUp breakPointsscriptSelectionchar 872 to 871 revUniqueID 1080366913202 bookmarks tempScript prevHandlermouseUpscript

on mouseUp

local tFileName, tDocID

-- tidy up any old trees first

send "mouseUp" to btn "CloseAll"

answer file "Select XML file" as sheet

put it into tFileName

if tFileName is empty then exit to top

if isMacOS9() then put revMacFromUnixPath(tFileName) into tFileName

-- read the file data and parse it into an XML tree in a single step

-- this may not work with Mac OS 9

-- parseBadData is set to false so incorrect data will be rejected

-- createTree is true and sendMessages is false

addToTranscript "revCreateXMLTreeFromFile(" & q(tFileName) & " ,false, true, false)"

put revCreateXMLTreeFromFile(tFileName, false, true, false) into tDocID

checkForError tDocID

put tDocID into fld "DocID"

-- format & display the text version of the newly loaded XML document

put formatXMLtext(tDocID) into fld "XMLtext"

end mouseUp

Read then createE8on mouseUp local tFileName, tData, tDocID -- tidy up any old trees first send "mouseUp" to btn "CloseAll" answer file "Select XML file" as sheet put it into tFileName if tFileName is empty then exit to top -- read the selected file into memory as a first step put URL ("file:" & tFileName) into tData -- parse the read data into an XML tree in the second step -- parseBadData is set to false so incorrect data will be rejected -- createTree is true and sendMessages is false addToTranscript "revCreateXMLTree(tData, false, true, false)" put revCreateXMLTree(tData, false, true, false) into tDocID checkForError tDocID put tDocID into fld "DocID" -- format & display the text version of the newly loaded XML document put formatXMLtext(tDocID) into fld "XMLtext" end mouseUp  cREVGeneral scriptChecksumB=^ MD breakPoints handlerListmouseUpscriptSelectionchar 824 to 823 bookmarks revUniqueID 1080373087268 prevHandlermouseUp tempScriptscript&

on mouseUp

local tFileName, tData, tDocID

-- tidy up any old trees first

send "mouseUp" to btn "CloseAll"

answer file "Select XML file" as sheet

put it into tFileName

if tFileName is empty then exit to top

-- read the selected file into memory as a first step

put URL ("file:" & tFileName) into tData

-- parse the read data into an XML tree in the second step

-- parseBadData is set to false so incorrect data will be rejected

-- createTree is true and sendMessages is false

addToTranscript "revCreateXMLTree(tData, false, true, false)"

put revCreateXMLTree(tData, false, true, false) into tDocID

checkForError tDocID

put tDocID into fld "DocID"

-- format & display the text version of the newly loaded XML document

put formatXMLtext(tDocID) into fld "XMLtext"

end mouseUp

Find by attributeE 7on mouseUp local tStart, tDocID, tParentNode, tNode, tChild, tFirst, tLast -- get an ID number between 1 & 4 to find put random(4) into tStart ask question "Enter an ID number to find:" with tStart as sheet put it into tStart if tStart is empty then exit to top if tStart < 1 then put 1 into tStart else if tStart > 4 then put 4 into tStart -- find the document ID - this routine creates one if there isn't one already put getTreeID() 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 -- find & display the node that matches the entered IDnum attribute entered -- start looking at the root node (tParentNode) -- leave the 3rd parameter empty so all child nodes will be scanned -- search for tStart in attribute "IDnum" -- the final parameter is used to limit how far down into the sub-nodes to search -- -1 means search all sub-nodes, no matter how deep addToTranscript "revXMLMatchingNode(" & tDocID & ", " & q(tParentNode) & ", , " & q("IDnum") & ", " & tStart & ", -1)" put revXMLMatchingNode(tDocID, tParentNode, , "IDnum", tStart, -1) into tNode addToTranscript tNode put tNode & cr & cr into fld "XMLtext" -- having found a matching node, show it's contents -- separate the element names from their data with tab -- and separate each node with cr (return) addToTranscript "revXMLChildContents(" & tDocID & ", " & q(tNode) & ", tab, cr, -1)" put revXMLChildContents(tDocID, tNode, tab, cr, true, -1) into tChild addToTranscript tChild put tChild after fld "XMLtext" -- now just pull out the firstName and lastName elements -- and display them in an answer dialog addToTranscript "revXMLNodeContents(" & tDocID & ", " & q(tNode & "/firstName") & ")" put revXMLNodeContents(tDocID, tNode & "/firstName") into tFirst addToTranscript tFirst addToTranscript "revXMLNodeContents(" & tDocID & ", " & q(tNode & "/lastName") & ")" put revXMLNodeContents(tDocID, tNode & "/lastName") into tLast addToTranscript tLast answer information "The full name for employee ID " & tStart & " is" & cr & \ tFirst && tLast as sheet end mouseUp 6 cREVGeneral scriptChecksumvF@>Y8IeK handlerListmouseUp breakPointsscriptSelection char 1 to 0 revUniqueID 1080366913202 bookmarks tempScript prevHandlermouseUpscript

on mouseUp

local tStart, tDocID, tParentNode, tNode, tChild, tFirst, tLast

-- get an ID number between 1 & 4 to find

put random(4) into tStart

ask question "Enter an ID number to find:" with tStart as sheet

put it into tStart

if tStart is empty then exit to top

if tStart < 1 then put 1 into tStart

else if tStart > 4 then put 4 into tStart

-- find the document ID - this routine creates one if there isn't one already

put getTreeID() 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

-- find & display the node that matches the entered IDnum attribute entered

-- start looking at the root node (tParentNode)

-- leave the 3rd parameter empty so all child nodes will be scanned

-- search for tStart in attribute "IDnum"

-- the final parameter is used to limit how far down into the sub-nodes to search

-- -1 means search all sub-nodes, no matter how deep

addToTranscript "revXMLMatchingNode(" & tDocID & ", " & q(tParentNode) & ", , " & q("IDnum") & ", " & tStart & ", -1)"

put revXMLMatchingNode(tDocID, tParentNode, , "IDnum", tStart, -1) into tNode

addToTranscript tNode

put tNode & cr & cr into fld "XMLtext"

-- having found a matching node, show it's contents

-- separate the element names from their data with tab

-- and separate each node with cr (return)

addToTranscript "revXMLChildContents(" & tDocID & ", " & q(tNode) & ", tab, cr, -1)"

put revXMLChildContents(tDocID, tNode, tab, cr, true, -1) into tChild

addToTranscript tChild

put tChild after fld "XMLtext"

-- now just pull out the firstName and lastName elements

-- and display them in an answer dialog

addToTranscript "revXMLNodeContents(" & tDocID & ", " & q(tNode & "/firstName") & ")"

put revXMLNodeContents(tDocID, tNode & "/firstName") into tFirst

addToTranscript tFirst

addToTranscript "revXMLNodeContents(" & tDocID & ", " & q(tNode & "/lastName") & ")"

put revXMLNodeContents(tDocID, tNode & "/lastName") into tLast

addToTranscript tLast

answer information "The full name for employee ID " & tStart & " is" & cr & \

tFirst && tLast as sheet

end mouseUp

Find by elementE .on mouseUp local tDocID, tParentNode, tLastName, tPhoneExt, tNumRecords local tNode, tRecord, tFoundName, tChild -- find the document ID - this routine creates one if there isn't one already put getTreeID() 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 -- pick a random lastName to search for put any item of "Jobs,Gates,Torvald,Miller" into tLastName put empty into tPhoneExt -- find out how many records there are in the parent or root node -- start counting at the parent node, count all child nodes (3rd parameter is empty) -- count only the parent's direct child nodes (4th parameter = 0) addToTranscript "revXMLNumberOfChildren( " & tDocID & ", " & q(tParentNode) & ", , 0)" put revXMLNumberOfChildren(tDocID, tParentNode, , 0) into tNumRecords addToTranscript tNumRecords -- move to the first node in the parent node addToTranscript "revXMLFirstChild(" & tDocID & ", " & q(tParentNode) & ")" put revXMLFirstChild(tDocID, tParentNode) into tNode addToTranscript tNode put tNode & cr into tRecord -- loop through each node repeat tNumRecords times -- check for a matching lastName element addToTranscript "revXMLNodeContents(" & tDocID & ", " & q(tNode & "/lastName") & ")" put revXMLNodeContents(tDocID, tNode & "/lastName") into tFoundName addToTranscript tFoundName if tFoundName = tLastName then -- pull out all the data for a matching record and display it -- separate the element names from their data with tab -- and separate each node with cr (return) addToTranscript "revXMLChildContents(" & tDocID & ", " & q(tNode) & ", tab, cr, true, -1)" put revXMLChildContents(tDocID, tNode, tab, cr, true, -1) into tChild addToTranscript tChild put tChild into fld "XMLtext" -- then separate out the matching phoneExt data addToTranscript "revXMLNodeContents(" & tDocID & ", " & q(tNode & "/phoneExt") & ")" put revXMLNodeContents(tDocID, tNode & "/phoneExt") into tPhoneExt addToTranscript tPhoneExt exit repeat end if -- if no match was found, use the address of the current node -- to move forwards to the next node addToTranscript "revXMLNextSibling(" & tDocID & ", " & q(tNode) & ")" put revXMLNextSibling(tDocID, tNode) into tNode addToTranscript tNode end repeat -- answer the matching phoneExt if tPhoneExt is not empty then answer information "The phone extension for " & tLastName & cr & "is " & tPhoneExt as sheet else answer error "Sorry, no record for " & tLastName & " can be found." as sheet end if end mouseUp 6 cREVGeneralscriptChecksumA N revUniqueID 1080366913202 bookmarks handlerListmouseUp tempScript prevHandlermouseUpscriptSelection char 1 to 0script}

on mouseUp

local tDocID, tParentNode, tLastName, tPhoneExt, tNumRecords

local tNode, tRecord, tFoundName, tChild

-- find the document ID - this routine creates one if there isn't one already

put getTreeID() 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

-- pick a random lastName to search for

put any item of "Jobs,Gates,Torvald,Miller" into tLastName

put empty into tPhoneExt

-- find out how many records there are in the parent or root node

-- start counting at the parent node, count all child nodes (3rd parameter is empty)

-- count only the parent's direct child nodes (4th parameter = 0)

addToTranscript "revXMLNumberOfChildren( " & tDocID & ", " & q(tParentNode) & ", , 0)"

put revXMLNumberOfChildren(tDocID, tParentNode, , 0) into tNumRecords

addToTranscript tNumRecords

-- move to the first node in the parent node

addToTranscript "revXMLFirstChild(" & tDocID & ", " & q(tParentNode) & ")"

put revXMLFirstChild(tDocID, tParentNode) into tNode

addToTranscript tNode

put tNode & cr into tRecord

-- loop through each node

repeat tNumRecords times

-- check for a matching lastName element

addToTranscript "revXMLNodeContents(" & tDocID & ", " & q(tNode & "/lastName") & ")"

put revXMLNodeContents(tDocID, tNode & "/lastName") into tFoundName

addToTranscript tFoundName

if tFoundName = tLastName then

-- pull out all the data for a matching record and display it

-- separate the element names from their data with tab

-- and separate each node with cr (return)

addToTranscript "revXMLChildContents(" & tDocID & ", " & q(tNode) & ", tab, cr, true, -1)"

put revXMLChildContents(tDocID, tNode, tab, cr, true, -1) into tChild

addToTranscript tChild

put tChild into fld "XMLtext"

-- then separate out the matching phoneExt data

addToTranscript "revXMLNodeContents(" & tDocID & ", " & q(tNode & "/phoneExt") & ")"

put revXMLNodeContents(tDocID, tNode & "/phoneExt") into tPhoneExt

addToTranscript tPhoneExt

exit repeat

end if

-- if no match was found, use the address of the current node

-- to move forwards to the next node

addToTranscript "revXMLNextSibling(" & tDocID & ", " & q(tNode) & ")"

put revXMLNextSibling(tDocID, tNode) into tNode

addToTranscript tNode

end repeat

-- answer the matching phoneExt

if tPhoneExt is not empty then

answer information "The phone extension for " & tLastName & cr & "is " & tPhoneExt as sheet

else

answer error "Sorry, no record for " & tLastName & " can be found." as sheet

end if

end mouseUp

Edit attributeE (on mouseUp local tStart, tDocID, tNode, tAttr, tChild, tNewAttr -- get an ID number between 1 & 4 to find put random(4) into tStart ask question "Enter a record number to edit:" with tStart as sheet put it into tStart if tStart is empty then exit to top if tStart < 1 then put 1 into tStart else if tStart > 4 then put 4 into tStart -- find the document ID - this routine creates one if there isn't one already put getTreeID() into tDocID -- setup the display field for text instead of an XML tree set the tabStops of fld "XMLtext" to 60 -- build the full node address for the randonly selected employee's record put "/employeeTable/employee[" & tStart & "]" into tNode -- show all the data for that employee: attributes & elements -- separate the attribute names from their data with 2 tabs for better alignment -- separate the element names from their data with tab -- and separate each node (attribute or element) with cr (return) put "Before editing:" & cr & cr into fld "XMLtext" addToTranscript "revXMLAttributes(" & tDocID & ", " & q(tNode) & ", tab & tab, cr)" put revXMLAttributes(tDocID, tNode, tab & tab, cr) & cr into tAttr put tAttr after fld "XMLtext" addToTranscript tAttr addToTranscript "revXMLChildContents(" & tDocID & " , " & q(tNode) & ", tab, cr, true, -1)" put revXMLChildContents(tDocID, tNode, tab, cr, true, -1) & cr & cr into tChild put tChild after fld "XMLtext" addToTranscript tChild -- change the IDnum attribute to a random number put random(100) into tNewAttr addToTranscript "revSetXMLAttribute " & tDocID & ", " & q(tNode) & ", " & q("IDnum") & " , " & q(tNewAttr) revSetXMLAttribute tDocID, tNode, "IDnum" , tNewAttr checkForError the result -- show all the edited data for that employee: attributes & elements put "After editing:" & cr & cr after fld "XMLtext" addToTranscript "revXMLAttributes(" & tDocID & ", " & q(tNode) & ", tab & tab, cr)" put revXMLAttributes(tDocID, tNode, tab & tab, cr) & cr into tAttr put tAttr after fld "XMLtext" addToTranscript tAttr addToTranscript "revXMLChildContents(" & tDocID & ", " & q(tNode) & ", tab, cr, true, -1)" put revXMLChildContents(tDocID, tNode, tab, cr, true, -1) & cr & cr into tChild put tChild after fld "XMLtext" addToTranscript tChild end mouseUp 6 cREVGeneralscriptChecksumYa7N6 revUniqueID 1080366913202 bookmarks handlerListmouseUp tempScript prevHandlermouseUpscriptSelection char 1 to 0scriptn

on mouseUp

local tStart, tDocID, tNode, tAttr, tChild, tNewAttr

-- get an ID number between 1 & 4 to find

put random(4) into tStart

ask question "Enter a record number to edit:" with tStart as sheet

put it into tStart

if tStart is empty then exit to top

if tStart < 1 then put 1 into tStart

else if tStart > 4 then put 4 into tStart

-- find the document ID - this routine creates one if there isn't one already

put getTreeID() into tDocID

-- setup the display field for text instead of an XML tree

set the tabStops of fld "XMLtext" to 60

-- build the full node address for the randonly selected employee's record

put "/employeeTable/employee[" & tStart & "]" into tNode

-- show all the data for that employee: attributes & elements

-- separate the attribute names from their data with 2 tabs for better alignment

-- separate the element names from their data with tab

-- and separate each node (attribute or element) with cr (return)

put "Before editing:" & cr & cr into fld "XMLtext"

addToTranscript "revXMLAttributes(" & tDocID & ", " & q(tNode) & ", tab & tab, cr)"

put revXMLAttributes(tDocID, tNode, tab & tab, cr) & cr into tAttr

put tAttr after fld "XMLtext"

addToTranscript tAttr

addToTranscript "revXMLChildContents(" & tDocID & " , " & q(tNode) & ", tab, cr, true, -1)"

put revXMLChildContents(tDocID, tNode, tab, cr, true, -1) & cr & cr into tChild

put tChild after fld "XMLtext"

addToTranscript tChild

-- change the IDnum attribute to a random number

put random(100) into tNewAttr

addToTranscript "revSetXMLAttribute " & tDocID & ", " & q(tNode) & ", " & q("IDnum") & " , " & q(tNewAttr)

revSetXMLAttribute tDocID, tNode, "IDnum" , tNewAttr

checkForError the result

-- show all the edited data for that employee: attributes & elements

put "After editing:" & cr & cr after fld "XMLtext"

addToTranscript "revXMLAttributes(" & tDocID & ", " & q(tNode) & ", tab & tab, cr)"

put revXMLAttributes(tDocID, tNode, tab & tab, cr) & cr into tAttr

put tAttr after fld "XMLtext"

addToTranscript tAttr

addToTranscript "revXMLChildContents(" & tDocID & ", " & q(tNode) & ", tab, cr, true, -1)"

put revXMLChildContents(tDocID, tNode, tab, cr, true, -1) & cr & cr into tChild

put tChild after fld "XMLtext"

addToTranscript tChild

end mouseUp

 Edit elementE *on mouseUp local tStart, tDocID, tNode, tAttr, tChild, tNewPark -- get an ID number between 1 & 4 to find put random(4) into tStart ask question "Enter a record number to edit:" with tStart as sheet put it into tStart if tStart is empty then exit to top if tStart < 1 then put 1 into tStart else if tStart > 4 then put 4 into tStart -- find the document ID - this routine creates one if there isn't one already put getTreeID() into tDocID -- setup the display field for text instead of an XML tree set the tabStops of fld "XMLtext" to 60 -- build the full node address for the randonly selected employee's record put "/employeeTable/employee[" & tStart & "]" into tNode -- show all the data for that employee: attributes & elements -- separate the attribute names from their data with 2 tabs for better alignment -- separate the element names from their data with tab -- and separate each node (attribute or element) with cr (return) put "Before editing:" & cr & cr into fld "XMLtext" addToTranscript "revXMLAttributes(" & tDocID & ", " & q(tNode) & ", tab & tab, cr)" put revXMLAttributes(tDocID, tNode, tab & tab, cr) & cr into tAttr put tAttr after fld "XMLtext" addToTranscript tAttr addToTranscript "revXMLChildContents(" & tDocID & ", " & q(tNode) & ", tab, cr, true, -1)" put revXMLChildContents(tDocID, tNode, tab, cr, true, -1) & cr & cr into tChild put tChild after fld "XMLtext" addToTranscript tChild -- change the parkingSlot element to a random number put random(999) into tNewPark addToTranscript "revPutIntoXMLNode " & tDocID & ", " & q(tNode & "/parkingSlot") & ", " & tNewPark revPutIntoXMLNode tDocID, tNode & "/parkingSlot", tNewPark checkForError the result -- show all the edited data for that employee: attributes & elements put "After editing:" & cr & cr after fld "XMLtext" addToTranscript "revXMLAttributes(" & tDocID & ", " & q(tNode) & ", tab & tab, cr)" put revXMLAttributes(tDocID, tNode, tab & tab, cr) & cr into tAttr put tAttr after fld "XMLtext" addToTranscript tAttr addToTranscript "revXMLChildContents(" & tDocID & ", " & q(tNode) & ", tab, cr, true, -1)" put revXMLChildContents(tDocID, tNode, tab, cr, true, -1) & cr & cr into tChild put tChild after fld "XMLtext" addToTranscript tChild end mouseUp 6 cREVGeneral scriptChecksumfŁU>UŦtKA handlerListmouseUp breakPointsscriptSelection char 1 to 0 revUniqueID 1080366913202 bookmarks tempScript prevHandlermouseUpscript

on mouseUp

local tStart, tDocID, tNode, tAttr, tChild, tNewPark

-- get an ID number between 1 & 4 to find

put random(4) into tStart

ask question "Enter a record number to edit:" with tStart as sheet

put it into tStart

if tStart is empty then exit to top

if tStart < 1 then put 1 into tStart

else if tStart > 4 then put 4 into tStart

-- find the document ID - this routine creates one if there isn't one already

put getTreeID() into tDocID

-- setup the display field for text instead of an XML tree

set the tabStops of fld "XMLtext" to 60

-- build the full node address for the randonly selected employee's record

put "/employeeTable/employee[" & tStart & "]" into tNode

-- show all the data for that employee: attributes & elements

-- separate the attribute names from their data with 2 tabs for better alignment

-- separate the element names from their data with tab

-- and separate each node (attribute or element) with cr (return)

put "Before editing:" & cr & cr into fld "XMLtext"

addToTranscript "revXMLAttributes(" & tDocID & ", " & q(tNode) & ", tab & tab, cr)"

put revXMLAttributes(tDocID, tNode, tab & tab, cr) & cr into tAttr

put tAttr after fld "XMLtext"

addToTranscript tAttr

addToTranscript "revXMLChildContents(" & tDocID & ", " & q(tNode) & ", tab, cr, true, -1)"

put revXMLChildContents(tDocID, tNode, tab, cr, true, -1) & cr & cr into tChild

put tChild after fld "XMLtext"

addToTranscript tChild

-- change the parkingSlot element to a random number

put random(999) into tNewPark

addToTranscript "revPutIntoXMLNode " & tDocID & ", " & q(tNode & "/parkingSlot") & ", " & tNewPark

revPutIntoXMLNode tDocID, tNode & "/parkingSlot", tNewPark

checkForError the result

-- show all the edited data for that employee: attributes & elements

put "After editing:" & cr & cr after fld "XMLtext"

addToTranscript "revXMLAttributes(" & tDocID & ", " & q(tNode) & ", tab & tab, cr)"

put revXMLAttributes(tDocID, tNode, tab & tab, cr) & cr into tAttr

put tAttr after fld "XMLtext"

addToTranscript tAttr

addToTranscript "revXMLChildContents(" & tDocID & ", " & q(tNode) & ", tab, cr, true, -1)"

put revXMLChildContents(tDocID, tNode, tab, cr, true, -1) & cr & cr into tChild

put tChild after fld "XMLtext"

addToTranscript tChild

end mouseUp

# Show treeEZon mouseUp local tDocID, tParentNode -- find the document ID - this routine creates one if there isn't one already put getTreeID() into tDocID -- find the root tag for this tree addToTranscript "revXMLRootNode(" & tDocID & ")" put revXMLRootNode(tDocID) into tParentNode addToTranscript tParentNode -- display the tree structure for this tree starting with the parent node -- separate nodes with cr (return) -- pad sub-nodes with tab so childreen are shown indented from their parent node -- for each node, show it's index number in square brackets (5th parameter = true) -- show all generations (6th parameter = -1) addToTranscript "revXMLTree(" & tDocID & ", " & q(tParentNode) & ", cr, tab, true, -1)" put revXMLTree(tDocID, tParentNode, cr, tab, true, -1) into fld "XMLtext" addToTranscript the result end mouseUp  cREVGeneral scriptChecksumgtH$)1 handlerListmouseUp breakPointsscriptSelection char 1 to 0 revUniqueID 1080366913202 bookmarks tempScript prevHandlermouseUpscript

on mouseUp

local tDocID, tParentNode

-- find the document ID - this routine creates one if there isn't one already

put getTreeID() into tDocID

-- find the root tag for this tree

addToTranscript "revXMLRootNode(" & tDocID & ")"

put revXMLRootNode(tDocID) into tParentNode

addToTranscript tParentNode

-- display the tree structure for this tree starting with the parent node

-- separate nodes with cr (return)

-- pad sub-nodes with tab so childreen are shown indented from their parent node

-- for each node, show it's index number in square brackets (5th parameter = true)

-- show all generations (6th parameter = -1)

addToTranscript "revXMLTree(" & tDocID & ", " & q(tParentNode) & ", cr, tab, true, -1)"

put revXMLTree(tDocID, tParentNode, cr, tab, true, -1) into fld "XMLtext"

addToTranscript the result

end mouseUp

$ Show dataE on mouseUp local tDocID -- find the document ID - this routine creates one if there isn't one already put getTreeID() into tDocID -- show the formatted tree data, instead of the tree structure put formatXMLtext(tDocID) into fld "XMLtext" end mouseUp  cREVGeneral scriptChecksumU<'x8 breakPoints handlerListmouseUpscriptSelectionchar 228 to 227 bookmarks revUniqueID 1080373087268 prevHandlerdoFormat tempScriptscript}

on mouseUp

local tDocID

-- find the document ID - this routine creates one if there isn't one already

put getTreeID() into tDocID

-- show the formatted tree data, instead of the tree structure

put formatXMLtext(tDocID) into fld "XMLtext"

end mouseUp

&BlankerK@2 cREVGeneral revUniqueID 1080459870221'BlankerK@2 cREVGeneral revUniqueID 1080459870221(BlankerK@2 cREVGeneral revUniqueID 1080459870221*Reset sample dataE -- This closes any existing XML trees and re-creates a new tree with the sample data. -- the handler for this is in the stack script -- -- Special case for tree display card -- adds an extra phone extension to one of the records -- on mouseUp local tDocID, tParentNode, tNode resetSampleData -- find the document ID - this routine creates one if there isn't one already put getTreeID() into tDocID -- find the root nade put revXMLRootNode(tDocID) into tParentNode -- find the address of the node with IDnum = 1 put revXMLMatchingNode(tDocID, tParentNode, , "IDnum", 1, -1) into tNode -- add a new phoneExt element to this node revAddXMLNode tDocID, tNode, "phoneExt", "007" -- display the XML text put formatXMLtext(tDocID) into fld "XMLtext" end mouseUp  cREVGeneralscriptChecksumʯJ^ bookmarks revUniqueID 1081751228270 handlerListmouseUpscriptSelectionchar 800 to 799 prevHandlermouseUp tempScriptscriptH

-- This closes any existing XML trees and re-creates a new tree with the sample data.

-- the handler for this is in the stack script

--

-- Special case for tree display card

-- adds an extra phone extension to one of the records

--

on mouseUp

local tDocID, tParentNode, tNode

resetSampleData

-- find the document ID - this routine creates one if there isn't one already

put getTreeID() into tDocID

-- find the root nade

put revXMLRootNode(tDocID) into tParentNode

-- find the address of the node with IDnum = 1

put revXMLMatchingNode(tDocID, tParentNode, , "IDnum", 1, -1) into tNode

-- add a new phoneExt element to this node

revAddXMLNode tDocID, tNode, "phoneExt", "007"

-- display the XML text

put formatXMLtext(tDocID) into fld "XMLtext"

end mouseUp

,Delete sub-nodeEon mouseUp local tStart, tDocID, tNode -- get an ID number between 1 & 4 to find put random(4) into tStart ask question "Enter a record number to delete their parking slot:" with tStart as sheet put it into tStart if tStart is empty then exit to top if tStart < 1 then put 1 into tStart else if tStart > 4 then put 4 into tStart -- find the document ID - this routine creates one if there isn't one already put getTreeID() into tDocID -- build the full node address for the randonly selected employee's record put "/employeeTable/employee[" & tStart & "]" into tNode -- delete the parkingSlot node for the selected node addToTranscript "revDeleteXMLNode " & tDocID & ", " & q(tNode & "/parkingSlot") revDeleteXMLNode tDocID, tNode & "/parkingSlot" checkForError the result -- completely display the edited XML tree put formatXMLtext(tDocID) into fld "XMLtext" end mouseUp  cREVGeneral scriptChecksumX>[,ż0Ȍ breakPoints handlerListmouseUpscriptSelectionchar 924 to 923 bookmarks revUniqueID 1080366913202 prevHandlermouseUp tempScriptscript

on mouseUp

local tStart, tDocID, tNode

-- get an ID number between 1 & 4 to find

put random(4) into tStart

ask question "Enter a record number to delete their parking slot:" with tStart as sheet

put it into tStart

if tStart is empty then exit to top

if tStart < 1 then put 1 into tStart

else if tStart > 4 then put 4 into tStart

-- find the document ID - this routine creates one if there isn't one already

put getTreeID() into tDocID

-- build the full node address for the randonly selected employee's record

put "/employeeTable/employee[" & tStart & "]" into tNode

-- delete the parkingSlot node for the selected node

addToTranscript "revDeleteXMLNode " & tDocID & ", " & q(tNode & "/parkingSlot")

revDeleteXMLNode tDocID, tNode & "/parkingSlot"

checkForError the result

-- completely display the edited XML tree

put formatXMLtext(tDocID) into fld "XMLtext"

end mouseUp

-Delete recordEKon mouseUp local tStart, tDocID, tNode -- get an ID number between 1 & 4 to find put random(4) into tStart ask question "Enter a record number for deletion:" with tStart as sheet put it into tStart if tStart is empty then exit to top if tStart is empty then exit to top if tStart < 1 then put 1 into tStart -- find the document ID - this routine creates one if there isn't one already put getTreeID() into tDocID -- build the full node address for the randonly selected employee's record put "/employeeTable/employee[" & tStart & "]" into tNode -- delete the selected node addToTranscript "revDeleteXMLNode " & tDocID & ", " & q(tNode) revDeleteXMLNode tDocID, tNode checkForError the result -- completely display the edited XML tree put formatXMLtext(tDocID) into fld "XMLtext" end mouseUp  cREVGeneral scriptChecksumԴ/ ~j] handlerListmouseUp breakPointsscriptSelectionchar 843 to 842 revUniqueID 1080373087268 bookmarks tempScript prevHandlermouseUpscript

on mouseUp

local tStart, tDocID, tNode

-- get an ID number between 1 & 4 to find

put random(4) into tStart

ask question "Enter a record number for deletion:" with tStart as sheet

put it into tStart

if tStart is empty then exit to top

if tStart is empty then exit to top

if tStart < 1 then put 1 into tStart

-- find the document ID - this routine creates one if there isn't one already

put getTreeID() into tDocID

-- build the full node address for the randonly selected employee's record

put "/employeeTable/employee[" & tStart & "]" into tNode

-- delete the selected node

addToTranscript "revDeleteXMLNode " & tDocID & ", " & q(tNode)

revDeleteXMLNode tDocID, tNode

checkForError the result

-- completely display the edited XML tree

put formatXMLtext(tDocID) into fld "XMLtext"

end mouseUp

2Add new attributeEon mouseUp local tStart, tDocID, tNode, tSecond -- get an ID number between 1 & 4 to find put random(4) into tStart ask question "Enter a record number to add a second ID attribute to:" with tStart as sheet put it into tStart if tStart is empty then exit to top if tStart < 1 then put 1 into tStart else if tStart > 4 then put 4 into tStart -- find the document ID - this routine creates one if there isn't one already put getTreeID() into tDocID -- build the full node address for the randomly selected employee's record put "/employeeTable/employee[" & tStart & "]" into tNode -- add a secondID attribute to the selected node put random(99) into tSecond addToTranscript "revSetXMLAttribute " & tDocID & ", " & q(tNode) & ", " & q("secondID") & ", " & tSecond revSetXMLAttribute tDocID, tNode, "secondID", tSecond checkForError the result -- completely display the edited XML tree put formatXMLtext(tDocID) into fld "XMLtext" end mouseUp  cREVGeneral scriptChecksum.BܦgE breakPoints handlerListmouseUpscriptSelectionchar 994 to 993 bookmarks revUniqueID 1080366913202 prevHandlermouseUp tempScriptscript D

on mouseUp

local tStart, tDocID, tNode, tSecond

-- get an ID number between 1 & 4 to find

put random(4) into tStart

ask question "Enter a record number to add a second ID attribute to:" with tStart as sheet

put it into tStart

if tStart is empty then exit to top

if tStart < 1 then put 1 into tStart

else if tStart > 4 then put 4 into tStart

-- find the document ID - this routine creates one if there isn't one already

put getTreeID() into tDocID

-- build the full node address for the randomly selected employee's record

put "/employeeTable/employee[" & tStart & "]" into tNode

-- add a secondID attribute to the selected node

put random(99) into tSecond

addToTranscript "revSetXMLAttribute " & tDocID & ", " & q(tNode) & ", " & q("secondID") & ", " & tSecond

revSetXMLAttribute tDocID, tNode, "secondID", tSecond

checkForError the result

-- completely display the edited XML tree

put formatXMLtext(tDocID) into fld "XMLtext"

end mouseUp

3Add attribute to tagEon mouseUp local tStart, tDocID, tNode, tWindow -- get an ID number between 1 & 4 to find put random(4) into tStart ask question "Enter a record number to add a room number attribute to:" with tStart as sheet put it into tStart if tStart is empty then exit to top if tStart < 1 then put 1 into tStart else if tStart > 4 then put 4 into tStart -- find the document ID - this routine creates one if there isn't one already put getTreeID() into tDocID -- build the full node address for the randomly selected employee's room number put "/employeeTable/employee[" & tStart & "]/roomNum" into tNode -- add a new attribute to the selected node put any item of "true,false" into tWindow addToTranscript "revSetXMLAttribute " & tDocID & ", " & q(tNode) & ", " & q("hasWindow") & ", " & tWindow revSetXMLAttribute tDocID, tNode, "hasWindow", tWindow checkForError the result -- completely display the edited XML tree put formatXMLtext(tDocID) into fld "XMLtext" end mouseUp  cREVGeneral scriptChecksumpޯf:0w handlerListmouseUp breakPointsscriptSelectionchar 1019 to 1018 revUniqueID 1080373087268 bookmarks tempScript prevHandlermouseUpscript

on mouseUp

local tStart, tDocID, tNode, tWindow

-- get an ID number between 1 & 4 to find

put random(4) into tStart

ask question "Enter a record number to add a room number attribute to:" with tStart as sheet

put it into tStart

if tStart is empty then exit to top

if tStart < 1 then put 1 into tStart

else if tStart > 4 then put 4 into tStart

-- find the document ID - this routine creates one if there isn't one already

put getTreeID() into tDocID

-- build the full node address for the randomly selected employee's room number

put "/employeeTable/employee[" & tStart & "]/roomNum" into tNode

-- add a new attribute to the selected node

put any item of "true,false" into tWindow

addToTranscript "revSetXMLAttribute " & tDocID & ", " & q(tNode) & ", " & q("hasWindow") & ", " & tWindow

revSetXMLAttribute tDocID, tNode, "hasWindow", tWindow

checkForError the result

-- completely display the edited XML tree

put formatXMLtext(tDocID) into fld "XMLtext"

end mouseUp

4Add new elementsEon mouseUp local tDocID, tEmails, x, tNode -- find the document ID - this routine creates one if there isn't one already put getTreeID() into tDocID -- set up loop to add emailAddress element to the records put "s.jobs@apple.com,bill.gates@microsoft.com,,kevin@runrev.com" into tEmails repeat with x = 1 to 4 -- don't add emailAddress to record 3 to show how XML doesn't require all records to be the same if x = 3 then next repeat -- build the full node address for the randomly selected employee's record put "/employeeTable/employee[" & x & "]" into tNode -- add an emailAddress element to the current node addToTranscript "revAddXMLNode " & tDocID & ", " & q(tNode) & ", " & q("emailAddress") & \ ", " & q(item x of tEmails) revAddXMLNode tDocID, tNode, "emailAddress", item x of tEmails checkForError the result end repeat -- completely display the edited XML tree put formatXMLtext(tDocID) into fld "XMLtext" end mouseUp  cREVGeneral scriptChecksum<$W :' breakPoints handlerListmouseUpscriptSelectionchar 1009 to 1008 bookmarks revUniqueID 1080366913202 prevHandlermouseUp tempScriptscript~

on mouseUp

local tDocID, tEmails, x, tNode

-- find the document ID - this routine creates one if there isn't one already

put getTreeID() into tDocID

-- set up loop to add emailAddress element to the records

put "s.jobs@apple.com,bill.gates@microsoft.com,,kevin@runrev.com" into tEmails

repeat with x = 1 to 4

-- don't add emailAddress to record 3 to show how XML doesn't require all records to be the same

if x = 3 then next repeat

-- build the full node address for the randomly selected employee's record

put "/employeeTable/employee[" & x & "]" into tNode

-- add an emailAddress element to the current node

addToTranscript "revAddXMLNode " & tDocID & ", " & q(tNode) & ", " & q("emailAddress") & \

", " & q(item x of tEmails)

revAddXMLNode tDocID, tNode, "emailAddress", item x of tEmails

checkForError the result

end repeat

-- completely display the edited XML tree

put formatXMLtext(tDocID) into fld "XMLtext"

end mouseUp

5Add duplicateEon mouseUp local tStart, tDocID, tNode -- get an ID number between 1 & 4 to find put random(4) into tStart ask question "Enter a record number to add a second phone extension element:" with tStart as sheet put it into tStart if tStart is empty then exit to top if tStart < 1 then put 1 into tStart else if tStart > 4 then put 4 into tStart -- find the document ID - this routine creates one if there isn't one already put getTreeID() into tDocID -- build the full node address for the randomly selected employee's room number put "/employeeTable/employee[" & tStart & "]" into tNode -- add a second phoneExt element to the selected node put random(900) + 100 into newExt addToTranscript "revAddXMLNode " & tDocID & ", " & q(tNode) & ", " & q("phoneExt") & \ ", " & q(newExt) revAddXMLNode tDocID, tNode, "phoneExt", newExt checkForError the result -- completely display the edited XML tree put formatXMLtext(tDocID) into fld "XMLtext" end mouseUp  cREVGeneral scriptChecksum~.z ټ4 handlerListmouseUp breakPointsscriptSelectionchar 900 to 899 revUniqueID 1080373087268 bookmarks tempScript prevHandlermouseUpscript 

on mouseUp

local tStart, tDocID, tNode

-- get an ID number between 1 & 4 to find

put random(4) into tStart

ask question "Enter a record number to add a second phone extension element:" with tStart as sheet

put it into tStart

if tStart is empty then exit to top

if tStart < 1 then put 1 into tStart

else if tStart > 4 then put 4 into tStart

-- find the document ID - this routine creates one if there isn't one already

put getTreeID() into tDocID

-- build the full node address for the randomly selected employee's room number

put "/employeeTable/employee[" & tStart & "]" into tNode

-- add a second phoneExt element to the selected node

put random(900) + 100 into newExt

addToTranscript "revAddXMLNode " & tDocID & ", " & q(tNode) & ", " & q("phoneExt") & \

", " & q(newExt)

revAddXMLNode tDocID, tNode, "phoneExt", newExt

checkForError the result

-- completely display the edited XML tree

put formatXMLtext(tDocID) into fld "XMLtext"

end mouseUp

6 XMLconstructe5on mouseUp go to stack "XMLconstruct" end mouseUp 0>XML construction kit cREVGeneralscriptChecksumeg:,z bookmarks revUniqueID 1081805265145 handlerListmouseUpscriptSelection char 1 to 0 prevHandlermouseUp tempScriptscript

on mouseUp

go to stack "XMLconstruct"

end mouseUp

8BlankerK@l@$ cREVGeneral revUniqueID 10852195941759BlankerK@l@& cREVGeneralscriptChecksumُ B~ bookmarks revUniqueID 1085219594175 handlerListscriptSelection char 1 to 0 prevHandler tempScriptscript

:BlankerK@l@& cREVGeneral revUniqueID 1085219594175< XMLtutoriale'on mouseUp go to card 2 end mouseUp 0>Start revXML tutorial cREVGeneralscriptChecksumDˌ6bzf revUniqueID 1085986599391 bookmarks handlerListmouseUp tempScript prevHandlermouseUpscriptSelection char 1 to 0scriptt

on mouseUp

go to card 2

end mouseUp

=Info2 0 cREVGeneral bookmarks revUniqueID 1085987009064 handlerListscriptSelection char 1 to 0 prevHandler tempScriptscript ]The XML construction kit stack provides a graphical interface for creating an XML data tree. It's stack script includes some useful handlers for making this easier in your own stacks. As with all the scripts in these stacks, they are extensively commented.>AboutbCon mouseUp if the visible of grp "About" then if the visible of fld "History" then send mouseUp to btn "History" lock screen hide grp "About" unlock screen with visual effect "wipe up" replace the cVersionNum of this stack with "v.v" in fld "About" else lock screen replace "v.v" with the cVersionNum of this stack in fld "About" show grp "About" unlock screen with visual effect "wipe down" end if end mouseUp  About this stack...R cREVGeneralscriptChecksum(1(dM revUniqueID 1085987354217 bookmarks handlerListmouseUp tempScript prevHandlermouseUpscriptSelectionchar 119 to 118script

on mouseUp

if the visible of grp "About" then

if the visible of fld "History" then send mouseUp to btn "History"

lock screen

hide grp "About"

unlock screen with visual effect "wipe up"

replace the cVersionNum of this stack with "v.v" in fld "About"

else

lock screen

replace "v.v" with the cVersionNum of this stack in fld "About"

show grp "About"

unlock screen with visual effect "wipe down"

end if

end mouseUp

BAbouta \ cREVGeneral revUniqueID 1085987888306 ?About pon linkClicked pLink if pLink contains "@" then revMail pLink,,"XML tutorial 1, version" && the cVersionNum of this stack else revGoURL pLink end if end linkClicked @T  cREVGeneralscriptChecksumՙoޘΡ, revUniqueID 1085987479227 bookmarks handlerList linkClicked tempScript prevHandler linkClickedscriptSelectionchar 154 to 153script>

on linkClicked pLink

if pLink contains "@" then

revMail pLink,,"XML tutorial 1, version" && the cVersionNum of this stack

else

revGoURL pLink

end if

end linkClicked

 CXML tutorial part 1 version v.v by Sarah Reichelt This was written using Revolution 2.2 on Mac OS X. It has also been tested on Mac OS 9.2 and Windows XP. If you are using it on any other systems, please let me know what your experiences have been so I can confirm that it works, or provide workarounds for any problems. Coming in part 2: pcoverage of the XML commands not discussed yet, with special attention to using DTDs to validate your XML data. ,For updates, check http://www.troz.net/Rev/ADoneE8on mouseUp send "mouseUp" to btn "About" end mouseUp 2P cREVGeneral scriptChecksumx*ȜH; breakPoints handlerListmouseUpscriptSelection char 1 to 0 revUniqueID 1085987838942 bookmarks tempScript prevHandlermouseUpscript

on mouseUp

send "mouseUp" to btn "About"

end mouseUp

SHistoryE;on mouseUp if the visible of fld "History" then lock screen hide fld "History" unlock screen with visual effect "wipe down" very fast else lock screen set the vScroll of fld "History" to 0 show fld "History" unlock screen with visual effect "wipe up" very fast end if end mouseUp 2P cREVGeneral scriptChecksum5<1ZwX4L41 handlerListmouseUp breakPointsscriptSelectionchar 213 to 212 bookmarks revUniqueID 1088404776396 prevHandlermouseUp tempScriptscript*

on mouseUp

if the visible of fld "History" then

lock screen

hide fld "History"

unlock screen with visual effect "wipe down" very fast

else

lock screen

set the vScroll of fld "History" to 0

show fld "History"

unlock screen with visual effect "wipe up" very fast

end if

end mouseUp

DBlankerK@  cREVGeneral revUniqueID 1080459870221EBlankerK@  cREVGeneral revUniqueID 1080459870221GActioneon mouseUp put "If there was an example script for this section," & cr & \ "it would be performed now and the results" & cr & \ "displayed here." into fld "XMLtext" end mouseUp 6Perform script cREVGeneralscriptChecksum;HwB;} 6i bookmarks revUniqueID 1086476470054 handlerListmouseUpscriptSelection char 1 to 0 prevHandlermouseUp tempScriptscriptx

on mouseUp

put "If there was an example script for this section," & cr & \

"it would be performed now and the results" & cr & \

"displayed here." into fld "XMLtext"

end mouseUp

KConvert to textE2-- this converts the currently created XML tree to text -- and displays it without any further formatting -- on mouseUp local tDocID, tXMLtext -- find the document ID - this routine creates one if there isn't one already put getTreeID() into tDocID -- now use the original revXMLText function to show how -- the text would be displayed without extra formatting -- if the option key is down, use the undocumented third parameter to provide some formatting if the optionKey is down then addToTranscript "revXMLText(" & tDocID & ",,true)" put revXMLText(tDocID,,true) into tXMLtext addToTranscript tXMLtext else addToTranscript "revXMLText(" & tDocID & ")" put revXMLText(tDocID) into tXMLtext addToTranscript tXMLtext end if put tXMLtext into fld "XMLtext" end mouseUp  cREVGeneralscriptChecksumD焖ГT- bookmarks revUniqueID 1086505716640 handlerListmouseUpscriptSelectionchar 818 to 817 prevHandlermouseUp tempScriptscript|

-- this converts the currently created XML tree to text

-- and displays it without any further formatting

--

on mouseUp

local tDocID, tXMLtext

-- find the document ID - this routine creates one if there isn't one already

put getTreeID() into tDocID

-- now use the original revXMLText function to show how

-- the text would be displayed without extra formatting

-- if the option key is down, use the undocumented third parameter to provide some formatting

if the optionKey is down then

addToTranscript "revXMLText(" & tDocID & ",,true)"

put revXMLText(tDocID,,true) into tXMLtext

addToTranscript tXMLtext

else

addToTranscript "revXMLText(" & tDocID & ")"

put revXMLText(tDocID) into tXMLtext

addToTranscript tXMLtext

end if

put tXMLtext into fld "XMLtext"

end mouseUp

QHistorypuon mouseUp lock screen hide fld "History" unlock screen with visual effect "wipe down" very fast end mouseUp @^ ( cREVGeneralscriptChecksumUJOt:B bookmarks revUniqueID 1088404486544 handlerListmouseUpscriptSelectionchar 109 to 108 prevHandler tempScriptscript

on mouseUp

lock screen

hide fld "History"

unlock screen with visual effect "wipe down" very fast

end mouseUp

 1.2: 29 August 2004 2 allowed for display differences on Windows 2000. ' Fixed an error in transcript display. * Thanks to Alex Tweedly for the feedback. # Some undocumented features added. 1.1: 28 June 2004 < fixed bug in construction kit - findSelectedNode function. 6 better handling of Mac OS 9 file paths & formatting. 5 added ability to show transcript at bottom or side.  added version history. * Thanks to Jan Schenkel for the feedback.  1.0: 22 June 2004  initial releaseV `_R info.gif@*!!210002nGIF89a!!̙@@@̙fff33f,!!GH OBxE $C  x%M\y #E$y&F/_ɳϞC$ABA ʓN+DՙMmjmi g̥Fr XH:4+0ĉp["8P(nkR4^J.V5 -HgT\.V*˘3_6waa…+`ӨS6-0REZ-tU۬;K؛)86cW7Wtn.y4CE չd ^)wx|fT rϿ?gܹ'lu4UlH?!clip2gif 0.7.2 by Yves Piguet; cREVGeneral revUniqueID 1090027946760Q wininfo2.gif@ 210005'GIF89a 3!, GH@\80#J(_#ظ1C "GRD /2pLN0 ࿝Q\gO"ȼ) JsHGS^1Σ\!b8!Ò@LTϏNmw.˃K!6T)ЈMvJ*A_r+QmC[4փa~EYej"cho#5[_gBtrvJG,ܡ(߂!clip2gif 0.7.2 by Yves Piguet; cREVGeneral revUniqueID 1090027950401cREVTempMaster palindromeFramesfalse repeatCount-1inksrcCopysize1063threeDtruerect 176,0,208,32name wininfo2.gifhotSpot1,1 patterns fileNamecolors255,51,255 128,128,128 196,196,196 255,255,255 0,0,255 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0toolTip alwaysBuffertruelayer6 dontDitherfalsevisibletrue borderWidth2imagePixmapId54526258opaquetrueyHot1id202006 currentFrame1altId0 showBorderfalse disabledfalse maskPixmapId54526259number6xHot1owner card id 1002 frameCount1lockLocfalse frameRate1,1WDelete attributeEon mouseUp local tStart, tDocID, tNode -- get an ID number between 1 & 4 to find put random(4) into tStart ask question "Enter a record number to delete their ID number:" with tStart as sheet put it into tStart if tStart is empty then exit to top if tStart < 1 then put 1 into tStart else if tStart > 4 then put 4 into tStart -- find the document ID - this routine creates one if there isn't one already put getTreeID() into tDocID -- build the full node address for the randonly selected employee's record put "/employeeTable/employee[" & tStart & "]" into tNode -- delete the parkingSlot node for the selected node addToTranscript "revXMLRemoveAttribute " & tDocID & ", " & q(tNode) & ", " & q("IDnum") revXMLRemoveAttribute tDocID, tNode, "IDnum" checkForError the result -- completely display the edited XML tree put formatXMLtext(tDocID) into fld "XMLtext" end mouseUp 6 cREVGeneral scriptChecksum98u,x4 breakPoints handlerListmouseUpscriptSelectionchar 746 to 792 bookmarks revUniqueID 1080366913202 prevHandlermouseUp tempScript

on mouseUp

local tStart, tDocID, tNode

-- get an ID number between 1 & 4 to find

put random(4) into tStart

ask question "Enter a record number to delete their ID number:" with tStart as sheet

put it into tStart

if tStart is empty then exit to top

if tStart < 1 then put 1 into tStart

else if tStart > 4 then put 4 into tStart

-- find the document ID - this routine creates one if there isn't one already

put getTreeID() into tDocID

-- build the full node address for the randonly selected employee's record

put "/employeeTable/employee[" & tStart & "]" into tNode

-- delete the parkingSlot node for the selected node

addToTranscript "revXMLRemoveAttribute " & tDocID & ", " & q(tNode) & ", " & q("IDnum")

revXMLRemoveAttribute tDocID, tNode, "IDnum"

checkForError the result

-- completely display the edited XML tree

put formatXMLtext(tDocID) into fld "XMLtext"

end mouseUp

script

on mouseUp

local tStart, tDocID, tNode

-- get an ID number between 1 & 4 to find

put random(4) into tStart

ask question "Enter a record number to delete their ID number:" with tStart as sheet

put it into tStart

if tStart is empty then exit to top

if tStart < 1 then put 1 into tStart

else if tStart > 4 then put 4 into tStart

-- find the document ID - this routine creates one if there isn't one already

put getTreeID() into tDocID

-- build the full node address for the randonly selected employee's record

put "/employeeTable/employee[" & tStart & "]" into tNode

-- delete the parkingSlot node for the selected node

addToTranscript "revXMLRemoveAttribute " & tDocID & ", " & q(tNode) & ", " & q("IDnum")

revXMLRemoveAttribute tDocID, tNode, "IDnum"

checkForError the result

-- completely display the edited XML tree

put formatXMLtext(tDocID) into fld "XMLtext"

end mouseUp

 XMLconstructV------------------------------- -- XML construction kit library -- -- Sarah Reichelt, 2004 -- sarah@troz.net -- http://www.troz.net/Rev/ ------------------------------- -- This library contains a selection of useful handlers -- for setting up and displaying an XML tree using Revolution. -- Some of them are duplicates of the handlers in the main stack, -- but are included here for completeness. -- -- All handlers can be used with explicitVariables turned on. -- Create new XML tree using supplied root tag. -- -- Returns XML document ID if successful, -- or displays XML error message & exits to top if not -- function createNewXMLdoc pRootTag local tData, tDocID put checkTagName(pRootTag) into pRootTag put "<" & pRootTag & ">" into tData get revCreateXMLTree(tData, false, true, false) put the result into tDocID if word 1 of tDocID contains "xmlErr" then answer error tDocID as sheet exit to top else return tDocID end if end createNewXMLdoc -- Add a new XML element to the specified tree & node. -- -- Displays XML error message & exits to top if not successful. -- on addNewXMLElement pDocID, pParent, pTag, pData local tSubNode put checkTagName(pTag) into pTag revAddXMLNode pDocID, pParent, pTag, pData put the result into tSubNode if word 1 of tSubNode contains "xmlErr" then answer error tSubNode as sheet end if end addNewXMLElement -- Add a new XML attribute to the specified tree & node. -- -- Displays XML error message & exits to top if not successful. -- on addNewXMLAttribute pDocID, pParent, pTag, pData local tSubNode put checkTagName(pTag) into pTag revSetXMLAttribute pDocID, pParent, pTag, pData put the result into tSubNode if word 1 of tSubNode contains "xmlErr" then answer error tSubNode as sheet end if end addNewXMLAttribute -- Checks that a supplied tag name is valid. -- -- If it can't be made valid, this exits to top with an error, -- otherwise, it returns the corrected tag -- function checkTagName pTag local tCheck, isLetter -- check for valid tag name: must start with a letter and not start with "xml" put true into isLetter put charToNum(char 1 of pTag) into tCheck if tCheck < 65 or tCheck > 122 or (tCheck > 90 and tCheck < 97) then put false into isLetter if isLetter = false or char 1 to 3 of pTag = "xml" then answer error quote & pTag & quote & " is not a valid tag name" as sheet exit to top end if -- remove illegal characters from tag name replace space with empty in pTag replace "-" with empty in pTag replace "." with empty in pTag replace ":" with empty in pTag return pTag end checkTagName -- Function for retrieving the complete tree structure for an XML tree. -- The text returned will be formatted with tabs and carriage returns. -- function getXMLtree pDocID local tParentNode, tTree put revXMLRootNode(pDocID) into tParentNode if word 1 of tParentNode contains "xmlErr" then put tParentNode into tTree else put revXMLTree(pDocID, tParentNode, cr, tab, true, -1) into tTree end if if word 1 of tTree contains "xmlErr" then answer error tTree as sheet exit to top else return tTree end if end getXMLtree -- Custom function for formatting simple XML text data. -- It adds linefeeds and indents where appropriate to make the data more readable. -- It may not get it exactly right and complex XML files may take a while to process, -- but it should give a better representation than the raw text dump -- function formatXMLtext pDocID local tXML, tMaxLines, tNewXML, tLine, tStartTag, tEndTag, tNextLine, tEndLine local L, x, y put revXMLText(pDocID) into tXML replace "><" with ">" & cr & "<" in tXML replace "" with "/>" & cr in tXML replace "" with "" then get offset(">", tStartTag) put char 1 to it-1 of tStartTag into tStartTag end if put tStartTag into tEndTag put "/" after char 1 of tEndTag if tLine contains tStartTag and tLine contains tEndTag then next repeat put x + 1 into tNextLine get lineOffset(tEndTag, tXML, tNextLine) if it > 0 then put tNextLine + it - 1 into tEndLine repeat with y = tNextLine to tEndLine put tab before line y of tXML end repeat end if end repeat if last char of tXML = cr then delete last char of tXML return tXML end formatXMLtext -- Function for returning the path to the node currently selected in the tree display. -- Parameters are the complete tree listing and the data from the currently selected line. -- Like the formatXMLtext function, it may not get it right every time with complex XML documents. -- function findSelectedNode pTree, pAddress, pStartLine local tNode, tFinalTabs, tTabCount, tNewTabCount, x, tNextLine put line 1 of pTree into tNode if pStartLine = 1 then return tNode put 0 into tFinalTabs repeat while char 1 of pAddress = tab add 1 to tFinalTabs delete char 1 of pAddress end repeat put tFinalTabs into tTabCount put pAddress into tNode repeat with x = pStartLine-1 down to 1 put 0 into tNewTabCount put line x of pTree into tNextLine repeat while char 1 of tNextLine = tab add 1 to tNewTabCount delete char 1 of tNextLine end repeat if tNewTabCount < tTabCount then put word 1 of tNextLine & "/" before tNode put tNewTabCount into tTabCount end if end repeat return tNode end findSelectedNode wXML construction kit ULucida Grande WVerdana @UVerdana UVerdanacREVGeometryCachestackID1054 cREVGeneralscriptChecksumVr?ݱmq bookmarks handlerListjcreateNewXMLdoc addNewXMLElement addNewXMLAttribute checkTagName getXMLtree formatXMLtext findSelectedNode breakPoints tempScript prevHandlercreateNewXMLdocscriptSelectionchar 3686 to 3685script?

-------------------------------

-- XML construction kit library

--

-- © Sarah Reichelt, 2004

-- sarah@troz.net

-- http://www.troz.net/Rev/

-------------------------------

-- This library contains a selection of useful handlers

-- for setting up and displaying an XML tree using Revolution.

-- Some of them are duplicates of the handlers in the main stack,

-- but are included here for completeness.

--

-- All handlers can be used with explicitVariables turned on.

-- Create new XML tree using supplied root tag.

--

-- Returns XML document ID if successful,

-- or displays XML error message & exits to top if not

--

function createNewXMLdoc pRootTag

local tData, tDocID

put checkTagName(pRootTag) into pRootTag

put "<" & pRootTag & "></" & pRootTag & ">" into tData

get revCreateXMLTree(tData, false, true, false)

put the result into tDocID

if word 1 of tDocID contains "xmlErr" then

answer error tDocID as sheet

exit to top

else

return tDocID

end if

end createNewXMLdoc

-- Add a new XML element to the specified tree & node.

--

-- Displays XML error message & exits to top if not successful.

--

on addNewXMLElement pDocID, pParent, pTag, pData

local tSubNode

put checkTagName(pTag) into pTag

revAddXMLNode pDocID, pParent, pTag, pData

put the result into tSubNode

if word 1 of tSubNode contains "xmlErr" then

answer error tSubNode as sheet

end if

end addNewXMLElement

-- Add a new XML attribute to the specified tree & node.

--

-- Displays XML error message & exits to top if not successful.

--

on addNewXMLAttribute pDocID, pParent, pTag, pData

local tSubNode

put checkTagName(pTag) into pTag

revSetXMLAttribute pDocID, pParent, pTag, pData

put the result into tSubNode

if word 1 of tSubNode contains "xmlErr" then

answer error tSubNode as sheet

end if

end addNewXMLAttribute

-- Checks that a supplied tag name is valid.

--

-- If it can't be made valid, this exits to top with an error,

-- otherwise, it returns the corrected tag

--

function checkTagName pTag

local tCheck, isLetter

-- check for valid tag name: must start with a letter and not start with "xml"

put true into isLetter

put charToNum(char 1 of pTag) into tCheck

if tCheck < 65 or tCheck > 122 or (tCheck > 90 and tCheck < 97) then put false into isLetter

if isLetter = false or char 1 to 3 of pTag = "xml" then

answer error quote & pTag & quote & " is not a valid tag name" as sheet

exit to top

end if

-- remove illegal characters from tag name

replace space with empty in pTag

replace "-" with empty in pTag

replace "." with empty in pTag

replace ":" with empty in pTag

return pTag

end checkTagName

-- Function for retrieving the complete tree structure for an XML tree.

-- The text returned will be formatted with tabs and carriage returns.

--

function getXMLtree pDocID

local tParentNode, tTree

put revXMLRootNode(pDocID) into tParentNode

if word 1 of tParentNode contains "xmlErr" then

put tParentNode into tTree

else

put revXMLTree(pDocID, tParentNode, cr, tab, true, -1) into tTree

end if

if word 1 of tTree contains "xmlErr" then

answer error tTree as sheet

exit to top

else

return tTree

end if

end getXMLtree

-- Custom function for formatting simple XML text data.

-- It adds linefeeds and indents where appropriate to make the data more readable.

-- It may not get it exactly right and complex XML files may take a while to process,

-- but it should give a better representation than the raw text dump

--

function formatXMLtext pDocID

local tXML, tMaxLines, tNewXML, tLine, tStartTag, tEndTag, tNextLine, tEndLine

local L, x, y

put revXMLText(pDocID) into tXML

replace "><" with ">" & cr & "<" in tXML

replace "</" with "§§" in tXML

replace "<" with cr & "<" in tXML

replace "/>" with "/>" & cr in tXML

replace "§§" with "</" in tXML

replace "&gt;" & cr with cr in tXML -- needed when translating to Mac OS 9

filter tXML with "?*"

-- get rid of any excess white space at start or end of lines

-- lines containing only tabs need to be removed also

repeat for each line L in tXML

if the number of words in L < 1 then next repeat

put word 1 to -1 of L & cr after tNewXML

end repeat

put tNewXML into tXML

put the number of lines in tXML into tMaxLines

repeat with x = 2 to tMaxLines

put line x of tXML into tLine

put word 1 of tLine into tStartTag

if char 2 of tStartTag = "/" then next repeat

if tStartTag contains ">" then

get offset(">", tStartTag)

put char 1 to it-1 of tStartTag into tStartTag

end if

put tStartTag into tEndTag

put "/" after char 1 of tEndTag

if tLine contains tStartTag and tLine contains tEndTag then next repeat

put x + 1 into tNextLine

get lineOffset(tEndTag, tXML, tNextLine)

if it > 0 then

put tNextLine + it - 1 into tEndLine

repeat with y = tNextLine to tEndLine

put tab before line y of tXML

end repeat

end if

end repeat

if last char of tXML = cr then delete last char of tXML

return tXML

end formatXMLtext

-- Function for returning the path to the node currently selected in the tree display.

-- Parameters are the complete tree listing and the data from the currently selected line.

-- Like the formatXMLtext function, it may not get it right every time with complex XML documents.

--

function findSelectedNode pTree, pAddress, pStartLine

local tNode, tFinalTabs, tTabCount, tNewTabCount, x, tNextLine

put line 1 of pTree into tNode

if pStartLine = 1 then return tNode

put 0 into tFinalTabs

repeat while char 1 of pAddress = tab

add 1 to tFinalTabs

delete char 1 of pAddress

end repeat

put tFinalTabs into tTabCount

put pAddress into tNode

repeat with x = pStartLine-1 down to 1

put 0 into tNewTabCount

put line x of pTree into tNextLine

repeat while char 1 of tNextLine = tab

add 1 to tNewTabCount

delete char 1 of tNextLine

end repeat

if tNewTabCount < tTabCount then

put word 1 of tNextLine & "/" before tNode

put tNewTabCount into tTabCount

end if

end repeat

return tNode

end findSelectedNode

 construct P-- These handlers are only for display purposes and are specific to this stack -- All the general handlers are in the stack script. -- utility handler for getting the current XML tree's ID number -- & displaying both the tree structure and the formatted text. -- on displayXML pDocID local tParentNode put pDocID into fld "DocID" put getXMLtree(pDocID) into fld "Tree" put formatXMLtext(pDocID) into fld "XML" end displayXML -- handler to re-select the current node in the tree display -- after any operation that may have de-selected it -- on setHilite pLineNum set the hilitedLine of fld "Tree" to pLineNum send "mouseUp" to fld "Tree" end setHilite -- close all trees & tidy up the display on closing -- on closeStack send "mouseUp" to btn "Close" save this stack end closeStack -- The Geometry Manager doesn't always work -- so I write my own resize handler -- on resizeStack newW, newH put the rect of fld "XML" into tRect put newW - 14 into item 3 of tRect set the rect of fld "XML" to tRect put the loc of btn "Save" into tLoc put newW - 60 into item 1 of tLoc set the loc of btn "Save" to tLoc put the loc of btn "About" into tLoc put newW - 30 into item 1 of tLoc set the loc of btn "About" to tLoc end resizeStack on preOpenCard if the platform = "MacOS" then set the icon of btn "About" to 50002 else set the icon of btn "About" to 50001 end if end preOpenCard cREVGeometryCacheIDs$108659247385010511081808851725102310818056480411008108180766199710111081809079274102610818089391981025108180863248910181081808829618102210859874792271053108180771581710201085398627508104110818077345291015108180893670410481081807435487100910818076893081012108659212247610301081808626662101710859878389421054108539606245710341085398627525104210818056219321007108180744837310101081805562402100310853973763351033108539790802110381081808829571102110853979084931039108598135774210451081808760116101910853960741501049108539785214610371086592489691105210859802412931044108180853856810161081805568946100510853960745521050cREVGeometrycachetotal40order  cREVGeneralscriptChecksumqSHR"=i bookmarks handlerList7displayXML setHilite closeStack resizeStack preOpenCard breakPoints tempScript prevHandler resizeStackscriptSelectionchar 436 to 435script7

-- These handlers are only for display purposes and are specific to this stack

-- All the general handlers are in the stack script.

-- utility handler for getting the current XML tree's ID number

-- & displaying both the tree structure and the formatted text.

--

on displayXML pDocID

local tParentNode

put pDocID into fld "DocID"

put getXMLtree(pDocID) into fld "Tree"

put formatXMLtext(pDocID) into fld "XML"

end displayXML

-- handler to re-select the current node in the tree display

-- after any operation that may have de-selected it

--

on setHilite pLineNum

set the hilitedLine of fld "Tree" to pLineNum

send "mouseUp" to fld "Tree"

end setHilite

-- close all trees & tidy up the display on closing

--

on closeStack

send "mouseUp" to btn "Close"

save this stack

end closeStack

-- The Geometry Manager doesn't always work

-- so I write my own resize handler

--

on resizeStack newW, newH

put the rect of fld "XML" into tRect

put newW - 14 into item 3 of tRect

set the rect of fld "XML" to tRect

put the loc of btn "Save" into tLoc

put newW - 60 into item 1 of tLoc

set the loc of btn "Save" to tLoc

put the loc of btn "About" into tLoc

put newW - 30 into item 1 of tLoc

set the loc of btn "About" to tLoc

end resizeStack

on preOpenCard

if the platform = "MacOS" then

set the icon of btn "About" to 50002

else

set the icon of btn "About" to 50001

end if

end preOpenCard

   XML `@FPH cREVGeneralscriptChecksumُ B~ bookmarks revUniqueID 1081805562402 handlerListscriptSelection char 1 to 0 prevHandlermouseUp tempScriptscript

 `Q7aG Label o< cREVGeneral revUniqueID 1081805621932 Tree structure: Label F< cREVGeneral revUniqueID 1081805648041 XML data:CloseE-- delete all XML trees -- clear all the display fields -- go to the Create tab -- on mouseUp revDeleteAllXMLTrees put empty into fld "DocID" put empty into fld "Tree" put empty into fld "XML" put empty into fld "RootTag" put empty into fld "Tag" put empty into fld "Data" put empty into fld "Element" put empty into fld "ElementEdit" put empty into fld "ElementAdd" put empty into fld "NewData" put empty into fld "Attributes" set the menuHistory of btn "Tabs" to 1 end mouseUp n( cREVGeneralscriptChecksum.*j" revUniqueID 1081807435487 bookmarks handlerListmouseUp tempScript prevHandlermouseUpscriptSelection char 83 to 82scriptN

-- delete all XML trees

-- clear all the display fields

-- go to the Create tab

--

on mouseUp

revDeleteAllXMLTrees

put empty into fld "DocID"

put empty into fld "Tree"

put empty into fld "XML"

put empty into fld "RootTag"

put empty into fld "Tag"

put empty into fld "Data"

put empty into fld "Element"

put empty into fld "ElementEdit"

put empty into fld "ElementAdd"

put empty into fld "NewData"

put empty into fld "Attributes"

set the menuHistory of btn "Tabs" to 1

end mouseUp

LoadE-- load any XML file into memory, creating a tree and displaying the tree, -- the XML text and the root tag, beofre going to the Edit tab -- on mouseUp local tFileName, tData, tDocID -- tidy up any old trees first send "mouseUp" to btn "Close" answer file "Select XML file" as sheet put it into tFileName if tFileName is empty then exit to top if isMacOS9() then put revMacFromUnixPath(tFileName) into tFileName -- read the selected file into memory as a first step put URL ("file:" & tFileName) into tData -- parse the read data into an XML tree in the second step -- parseBadData is set to false so incorrect data will be rejected -- createTree is true and sendMessages is false put revCreateXMLTree(tData, false, true, false) into tDocID if tDocID contains "xmlerr" then answer error tDocID as sheet exit to top end if put tDocID into fld "DocID" displayXML tDocID put line 1 of fld "Tree" into fld "RootTag" set the menuHistory of btn "Tabs" to 3 setHilite 1 end mouseUp F\( cREVGeneralscriptChecksum]3ڑW\> bookmarks revUniqueID 1081807448373 handlerListmouseUpscriptSelectionchar 439 to 438 prevHandlermouseUp tempScriptscript

-- load any XML file into memory, creating a tree and displaying the tree,

-- the XML text and the root tag, beofre going to the Edit tab

--

on mouseUp

local tFileName, tData, tDocID

-- tidy up any old trees first

send "mouseUp" to btn "Close"

answer file "Select XML file" as sheet

put it into tFileName

if tFileName is empty then exit to top

if isMacOS9() then put revMacFromUnixPath(tFileName) into tFileName

-- read the selected file into memory as a first step

put URL ("file:" & tFileName) into tData

-- parse the read data into an XML tree in the second step

-- parseBadData is set to false so incorrect data will be rejected

-- createTree is true and sendMessages is false

put revCreateXMLTree(tData, false, true, false) into tDocID

if tDocID contains "xmlerr" then

answer error tDocID as sheet

exit to top

end if

put tDocID into fld "DocID"

displayXML tDocID

put line 1 of fld "Tree" into fld "RootTag"

set the menuHistory of btn "Tabs" to 3

setHilite 1

end mouseUp

Createi3U cREVGeneral revUniqueID 1081808538568 Label 7Y cREVGeneral revUniqueID 1081807689308 bookmarks handlerList tempScript prevHandlerscriptSelection char 1 to 0script Enter a name for the root tag: RootTagi`Ax cREVGeneral bookmarks revUniqueID 1081807715817 handlerListscriptSelection char 1 to 0 prevHandler tempScriptscript  CreateE-- create the new tree, display it's tree & text before going to the Add tab -- on mouseUp local tRoot, tDocID put fld "RootTag" into tRoot if tRoot is empty then answer error "Please enter a name for the root tag." exit to top end if -- create the new tree using the custom handler in the stack script put createNewXMLdoc(tRoot) into tDocID displayXML tDocID set the menuHistory of btn "Tabs" to 2 setHilite 1 end mouseUp S( cREVGeneralscriptChecksumhSjܗ]igR bookmarks revUniqueID 1081807734529 handlerListmouseUpscriptSelection char 80 to 79 prevHandlermouseUp tempScriptscript

-- create the new tree, display it's tree & text before going to the Add tab

--

on mouseUp

local tRoot, tDocID

put fld "RootTag" into tRoot

if tRoot is empty then

answer error "Please enter a name for the root tag."

exit to top

end if

-- create the new tree using the custom handler in the stack script

put createNewXMLdoc(tRoot) into tDocID

displayXML tDocID

set the menuHistory of btn "Tabs" to 2

setHilite 1

end mouseUp

Adda<M cREVGeneral revUniqueID 1081809079274 Label @ cREVGeneral revUniqueID 1081808851725 "Where the new tag is to be added:  ElementAddI`@W@ cREVGeneral revUniqueID 1085981357742 bookmarks handlerList tempScript prevHandlerscriptSelection char 1 to 0script  Label 9 cREVGeneral revUniqueID 1081808760116 Tag name: Tagi`A cREVGeneral bookmarks revUniqueID 1081807715817 handlerListscriptSelection char 1 to 0 prevHandler tempScriptscript  Label 9 cREVGeneral revUniqueID 1081808829571 Tag data (optional): Data)p4on openField select the text of me end openField AH cREVGeneralscriptChecksumdov9.4rm) bookmarks revUniqueID 1081808829618 handlerList openFieldscriptSelection char 1 to 0 prevHandler openField tempScriptscript

on openField

select the text of me

end openField

 `F Add elementE-- Add a new element to the currently selected tag -- using a custom handler in the stack script. -- Then display the tree and data with the new element hilited. -- on mouseUp local tDocID, tLine, tParent, tTag, tData put fld "DocID" into tDocID put the hilitedLine of fld "Tree" into tLine -- find the selected node from the XML tree put fld "ElementAdd" into tParent put fld "Tag" into tTag if tTag is empty then answer error "Please enter a name for the new tag." exit to top end if put fld "Data" into tData -- add the new element using the custom handler in the stack script addNewXMLElement tDocID, tParent, tTag, tData displayXML tDocID -- hilite the newly created element add 1 to tLine repeat until line tLine of fld "Tree" contains tTag add 1 to tLine if tLine > the number of lines in fld "Tree" then exit to top end repeat setHilite tLine end mouseUp SV( cREVGeneralscriptChecksumWސ{ Y bookmarks revUniqueID 1081808936704 handlerListmouseUpscriptSelectionchar 166 to 165 prevHandlermouseUp tempScriptscript

-- Add a new element to the currently selected tag

-- using a custom handler in the stack script.

-- Then display the tree and data with the new element hilited.

--

on mouseUp

local tDocID, tLine, tParent, tTag, tData

put fld "DocID" into tDocID

put the hilitedLine of fld "Tree" into tLine

-- find the selected node from the XML tree

put fld "ElementAdd" into tParent

put fld "Tag" into tTag

if tTag is empty then

answer error "Please enter a name for the new tag."

exit to top

end if

put fld "Data" into tData

-- add the new element using the custom handler in the stack script

addNewXMLElement tDocID, tParent, tTag, tData

displayXML tDocID

-- hilite the newly created element

add 1 to tLine

repeat until line tLine of fld "Tree" contains tTag

add 1 to tLine

if tLine > the number of lines in fld "Tree" then exit to top

end repeat

setHilite tLine

end mouseUp

Add attributeE-- Add a new attribute to the currently selected tag -- using a custom handler in the stack script. -- Then display the tree and data with the new attribute's parent element hilited. -- on mouseUp local tDocID, tLine, tParent, tTag, tData put fld "DocID" into tDocID put the hilitedLine of fld "Tree" into tLine -- find the selected node from the XML tree put fld "ElementAdd" into tParent put fld "Tag" into tTag if tTag is empty then answer error "Please enter a name for the new tag." exit to top end if put fld "Data" into tData -- add the new element using the custom handler in the stack script addNewXMLAttribute tDocID, tParent, tTag, tData displayXML tDocID -- hilite the newly created attribute setHilite tLine end mouseUp S( cREVGeneralscriptChecksum$$oDVo Q% revUniqueID 1081808939198 bookmarks handlerListmouseUp tempScript prevHandlermouseUpscriptSelection char 1 to 0script

-- Add a new attribute to the currently selected tag

-- using a custom handler in the stack script.

-- Then display the tree and data with the new attribute's parent element hilited.

--

on mouseUp

local tDocID, tLine, tParent, tTag, tData

put fld "DocID" into tDocID

put the hilitedLine of fld "Tree" into tLine

-- find the selected node from the XML tree

put fld "ElementAdd" into tParent

put fld "Tag" into tTag

if tTag is empty then

answer error "Please enter a name for the new tag."

exit to top

end if

put fld "Data" into tData

-- add the new element using the custom handler in the stack script

addNewXMLAttribute tDocID, tParent, tTag, tData

displayXML tDocID

-- hilite the newly created attribute

setHilite tLine

end mouseUp

 Edita<M cREVGeneral revUniqueID 1085396062457  Label @ cREVGeneral revUniqueID 1085396074150 (Currently selected element for editing:  ElementEditI`@W@ cREVGeneral bookmarks revUniqueID 1085397852146 handlerListscriptSelection char 1 to 0 prevHandler tempScriptscript  Label 9 cREVGeneral revUniqueID 1085397908021 Element data: NewData)p4on openField select the text of me end openField AH cREVGeneralscriptChecksumdov9.4rm) bookmarks revUniqueID 1085397908493 handlerList openFieldscriptSelection char 1 to 0 prevHandler openField tempScriptscript

on openField

select the text of me

end openField

 `F Edit elementEm-- Edit the currently selected element using a revXML library handler. -- Then display the tree and data with the edited element hilited. -- on mouseUp local tDocID, tNode, tLine put fld "DocID" into tDocID put fld "ElementEdit" into tNode put the hilitedLine of fld "Tree" into tLine if tLine = 1 then answer error "You can't edit the root element directly." exit to top end if if tNode is empty then answer error "Please select an element to delete." exit to top end if revPutIntoXMLNode tDocID, tNode, fld "NewData" displayXML tDocID setHilite tLine end mouseUp S( cREVGeneralscriptChecksumڐ$}7 revUniqueID 1081808936704 bookmarks handlerListmouseUp tempScript prevHandlermouseUpscriptSelection char 1 to 0script

-- Edit the currently selected element using a revXML library handler.

-- Then display the tree and data with the edited element hilited.

--

on mouseUp

local tDocID, tNode, tLine

put fld "DocID" into tDocID

put fld "ElementEdit" into tNode

put the hilitedLine of fld "Tree" into tLine

if tLine = 1 then

answer error "You can't edit the root element directly."

exit to top

end if

if tNode is empty then

answer error "Please select an element to delete."

exit to top

end if

revPutIntoXMLNode tDocID, tNode, fld "NewData"

displayXML tDocID

setHilite tLine

end mouseUp

Label 8) cREVGeneral revUniqueID 1085398627508 Attributes:  Attributes qNon mouseDoubleUp send "mouseUp" to btn "Edit attribute" end mouseDoubleUp @A@HP cREVGeneralscriptChecksumpMȱnvJfTY revUniqueID 1085398627525 bookmarks handlerList mouseDoubleUp tempScript prevHandler openFieldscriptSelection char 1 to 0script

on mouseDoubleUp

send "mouseUp" to btn "Edit attribute"

end mouseDoubleUp

 `A7aBwEdit attributeE-- Edit the currently selected attribute using a revXML library handler. -- Then display the tree and data with the current element hilited. -- on mouseUp local tLineNum, tLineData, tDocID, tNode, tLine, tAttrName, tAttrData put the hilitedLine of fld "Attributes" into tLineNum put line tLineNum of fld "Attributes" into tLineData if tLineData is empty then answer error "Please select an attribute for editing." exit to top end if put fld "DocID" into tDocID put fld "ElementEdit" into tNode put the hilitedLine of fld "Tree" into tLine set the itemDel to tab put item 1 of tLineData into tAttrName put item 2 of tLineData into tAttrData ask "Edit the " & tAttrName & " attribute to:" with tAttrData if the result = "Cancel" then exit to top put it into tAttrData revSetXMLAttribute tDocID, tNode, tAttrName, tAttrData displayXML tDocID setHilite tLine end mouseUp S( cREVGeneralscriptChecksumvW8LjO~ bookmarks revUniqueID 1085980241293 handlerListmouseUpscriptSelection char 1 to 0 prevHandlermouseUp tempScriptscript 

-- Edit the currently selected attribute using a revXML library handler.

-- Then display the tree and data with the current element hilited.

--

on mouseUp

local tLineNum, tLineData, tDocID, tNode, tLine, tAttrName, tAttrData

put the hilitedLine of fld "Attributes" into tLineNum

put line tLineNum of fld "Attributes" into tLineData

if tLineData is empty then

answer error "Please select an attribute for editing."

exit to top

end if

put fld "DocID" into tDocID

put fld "ElementEdit" into tNode

put the hilitedLine of fld "Tree" into tLine

set the itemDel to tab

put item 1 of tLineData into tAttrName

put item 2 of tLineData into tAttrData

ask "Edit the " & tAttrName & " attribute to:" with tAttrData

if the result = "Cancel" then exit to top

put it into tAttrData

revSetXMLAttribute tDocID, tNode, tAttrName, tAttrData

displayXML tDocID

setHilite tLine

end mouseUp

 SaveE -- Save the current XML tree data to a text file. -- on mouseUp local tFileName ask file "Save XML data as:" with "Data.xml" as sheet put it into tFileName if tFilename is not empty then put fld "XML" into URL ("file:" & tFileName) end if end mouseUp \( cREVGeneral scriptChecksumԃXONr breakPoints handlerListmouseUpscriptSelection char 1 to 0 revUniqueID 1085397376335 bookmarks tempScript prevHandlermouseUpscript

-- Save the current XML tree data to a text file.

--

on mouseUp

local tFileName

ask file "Save XML data as:" with "Data.xml" as sheet

put it into tFileName

if tFilename is not empty then

put fld "XML" into URL ("file:" & tFileName)

end if

end mouseUp

DocID > cREVGeneral bookmarks revUniqueID 1081808632489 handlerListscriptSelection char 1 to 0 prevHandler tempScriptscript Tree p-- this handler uses the findSelectedNode function in the stack script -- and displays its address, elements & attributes (if any) -- ready for adding to, editing or deleteing -- on mouseUp local tNode, tDocID, tAttr -- specify the current node from the XML tree (function in card script) put findSelectedNode(me, the selectedText of me, the hilitedLine of me) into tNode put tNode into fld "Element" put tNode into fld "ElementAdd" put tNode into fld "ElementEdit" -- show current data in Edit group put tNode into fld "ElementEdit" put fld "DocID" into tDocID put revXMLNodeContents(tDocID, tNode) into fld "NewData" put revXMLAttributes(tDocID, tNode, tab, cr) into tAttr put tAttr into fld "Attributes" if tAttr is empty then disable btn "Edit attribute" else set the hilitedLine of fld "Attributes" to 1 enable btn "Edit attribute" end if end mouseUp nPH cREVGeneralscriptChecksumDS<af bookmarks revUniqueID 1081805568946 handlerListmouseUpscriptSelection char 1 to 0 prevHandlermouseUp tempScriptscriptt

-- this handler uses the findSelectedNode function in the stack script

-- and displays its address, elements & attributes (if any)

-- ready for adding to, editing or deleteing

--

on mouseUp

local tNode, tDocID, tAttr

-- specify the current node from the XML tree (function in card script)

put findSelectedNode(me, the selectedText of me, the hilitedLine of me) into tNode

put tNode into fld "Element"

put tNode into fld "ElementAdd"

put tNode into fld "ElementEdit"

-- show current data in Edit group

put tNode into fld "ElementEdit"

put fld "DocID" into tDocID

put revXMLNodeContents(tDocID, tNode) into fld "NewData"

put revXMLAttributes(tDocID, tNode, tab, cr) into tAttr

put tAttr into fld "Attributes"

if tAttr is empty then

disable btn "Edit attribute"

else

set the hilitedLine of fld "Attributes" to 1

enable btn "Edit attribute"

end if

end mouseUp

`%QF Label oz cREVGeneral revUniqueID 1081808626662 XML document ID:Tabs} -- the tabs show & hide the appropriate groups -- all the controls on this stack are on the same card -- on menuPick pNew, pOld if there is a grp pOld then hide grp pOld if there is a grp pNew then show grp pNew end menuPick OCreate Add Edit Delete cREVGeneralscriptChecksum;_'m<6 revUniqueID 1081807661997 bookmarks handlerListmenuPick tempScript prevHandlermenuPickscriptSelection char 1 to 0scriptX

-- the tabs show & hide the appropriate groups

-- all the controls on this stack are on the same card

--

on menuPick pNew, pOld

if there is a grp pOld then hide grp pOld

if there is a grp pNew then show grp pNew

end menuPick

Deletea<M cREVGeneral revUniqueID 1086592122476 Label @ cREVGeneral revUniqueID 1085396074150 Element selected for deletion: ElementI`@W@ cREVGeneral revUniqueID 1085396074552  Delete elementE\-- Delete the currently selected element using a revXML library handler. -- Then display the tree and data with the previous element hilited. -- -- As deleting the root tag can often make Revolution crash, this has been prevented. -- on mouseUp local tDocID, tNode, tLine put fld "DocID" into tDocID put fld "Element" into tNode put the hilitedLine of fld "Tree" into tLine if tLine = 1 then answer error "Deleting the root element can cause Revolution to crash." & cr & \ "Do you want to close the tree instead?" with "Close" or "Leave it" as sheet if it = "Close" then send "mouseUp" to btn "Close" exit to top end if if tNode is empty then answer error "Please select an element to delete." exit to top end if revDeleteXMLNode tDocID, tNode displayXML tDocID setHilite tLine-1 end mouseUp S( cREVGeneralscriptChecksum>SpQ@ revUniqueID 1081808936704 bookmarks handlerListmouseUp tempScript prevHandlermouseUpscriptSelection char 1 to 0script M

-- Delete the currently selected element using a revXML library handler.

-- Then display the tree and data with the previous element hilited.

--

-- As deleting the root tag can often make Revolution crash, this has been prevented.

--

on mouseUp

local tDocID, tNode, tLine

put fld "DocID" into tDocID

put fld "Element" into tNode

put the hilitedLine of fld "Tree" into tLine

if tLine = 1 then

answer error "Deleting the root element can cause Revolution to crash." & cr & \

"Do you want to close the tree instead?" with "Close" or "Leave it" as sheet

if it = "Close" then send "mouseUp" to btn "Close"

exit to top

end if

if tNode is empty then

answer error "Please select an element to delete."

exit to top

end if

revDeleteXMLNode tDocID, tNode

displayXML tDocID

setHilite tLine-1

end mouseUp

AboutbCon mouseUp local tLoc if the visible of grp "About" then lock screen hide grp "About" unlock screen with visual effect "wipe up" very fast else lock screen put the loc of grp "About" into tLoc put the width of this stack div 2 into item 1 of tLoc set the loc of grp "About" to tLoc show grp "About" unlock screen with visual effect "wipe down" very fast end if end mouseUp  R cREVGeneralscriptChecksumސv!X|Gٷ revUniqueID 1086592473850 bookmarks handlerListmouseUp tempScript prevHandlermouseUpscriptSelectionchar 399 to 398script6

on mouseUp

local tLoc

if the visible of grp "About" then

lock screen

hide grp "About"

unlock screen with visual effect "wipe up" very fast

else

lock screen

put the loc of grp "About" into tLoc

put the width of this stack div 2 into item 1 of tLoc

set the loc of grp "About" to tLoc

show grp "About"

unlock screen with visual effect "wipe down" very fast

end if

end mouseUp

Abouta  cREVGeneral revUniqueID 1086592489691 About `@  cREVGeneralscriptChecksumُ B~ revUniqueID 1085987479227 bookmarks handlerList tempScript prevHandler linkClickedscriptSelection char 1 to 0script

 :This stack allows you to create new XML documents easily. EYou can also load in existing XML documents to examine or edit them. VAfter creating or editing, save the documents if you want to keep what you have done.DoneE8on mouseUp send "mouseUp" to btn "About" end mouseUp fP cREVGeneralscriptChecksumx*ȜH; revUniqueID 1085987838942 bookmarks handlerListmouseUp tempScript prevHandlermouseUpscriptSelection char 1 to 0script

on mouseUp

send "mouseUp" to btn "About"

end mouseUp

XMLtranscript]XML transcript UVerdana WVerdanacREVGeometryCachestackID1007 @cREVGeometryCacheIDs108411776092210031084118315108100710841183105381006cREVGeometrycachetotal3order*1084117760922 1084118315108 1084118310538  XMLtranscript)h @ K cREVGeometryMaster,scaleBottomObjectSideBottomMaster,movehDistancefalseMastertrueMaster,scaleBottomObjectRefcardMaster,scaleBottomAbsolutetrueMaster,scaleBottomtrueMaster,movevDistancefalseMaster,scalebottomDistance-43Master,expectedRect 10,10,390,437Master,scaleRightAbsolutetrueMaster,scaleRighttrueMaster,scalerightDistance-10Master,scaleRightObjectRefcardMaster,scaleRightObjectSideRightMaster,cardRanking2Master,scaletopDistanceMaster,scaleleftDistance cREVGeneral bookmarks revUniqueID 1084117760922 handlerListscriptSelection char 1 to 0 prevHandler tempScriptscript  ` a ClearE=on mouseUp put empty into fld "XMLtranscript" end mouseUp R cREVGeometry Master,movevDistance-22Master,scalebottomDistanceMaster,expectedRect 10,447,92,470Master,moveVObjectSidebottomMaster,movehDistancefalseMastertrueMaster,moveVObjectRefcardMaster,scalerightDistanceMaster,cardRanking1Master,moveVAbsolutetrue Master,moveVtrueMaster,scaletopDistanceMaster,scaleleftDistance cREVGeneralscriptChecksum(̓pMF:osё bookmarks revUniqueID 1084118310538 handlerListmouseUpscriptSelection char 48 to 47 prevHandler tempScriptscript

on mouseUp

put empty into fld "XMLtranscript"

end mouseUp

CloseEon mouseUp save this stack close this stack set the label of btn "Transcript" of cd 2 of stack "XMLdemo1" to "Show transcript" end mouseUp oR cREVGeometryMaster,moveVObjectSidebottomMaster,movehDistance-60MastertrueMaster,moveVObjectRefcardMaster,moveHObjectRefcardMaster,moveVAbsolutetrue Master,moveVtrueMaster,movevDistance-22Master,scalebottomDistanceMaster,expectedRect111,423,193,446Master,moveHObjectSiderightMaster,scalerightDistanceMaster,cardRanking2Master,moveHAbsolutetrueMaster,scaletopDistanceMaster,scaleleftDistance Master,moveHtrue cREVGeneralscriptChecksumDnȞ``9h bookmarks revUniqueID 1084118315108 handlerListmouseUpscriptSelection char 95 to 94 prevHandlermouseUp tempScriptscriptb

on mouseUp

save this stack

close this stack

set the label of btn "Transcript" of cd 2 of stack "XMLdemo1" to "Show transcript"

end mouseUp