help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-smalltalk] XML usage question..


From: Rick Flower
Subject: [Help-smalltalk] XML usage question..
Date: Tue, 25 Sep 2012 09:51:34 -0700
User-agent: Apple Webmail/0.6

Hi all..

So, I've got an XML file that looks like the following :

<?xml version="1.0"?>
<!DOCTYPE requirements [
<!ELEMENT requirements (UseCase+)>
<!ELEMENT UseCase                     (#PCDATA)>
<!ELEMENT UseCases                    (UseCase+)>
]>
<requirements>
        <UseCases>
                <UseCase>Use-Case #1</UseCase>
                <UseCase>Use-Case #2</UseCase>
        </UseCases>
</requirements>


I then have the following code to parse & read in the XML :

==============================================================
buildUseCaseCollectionFrom: aList [
aList detect: [:each | Transcript show: 'Element:' , (each characterData); cr ]
]

 stream := './requirements.xml' asFile readStream.
 parser := XML.XMLParser new.
 parser validate: false.
 parser parse: stream.

 docroot := parser document root.
 self buildUseCaseCollectionFrom: (docroot elementsNamed: 'UseCases').

==============================================================

When I run it, I get the following output -- seems
like the Collection of Use-Case Elements is not
quite right.. I was expecting two "Element:" lines
each with the respective Use-Case # element but not
both bunched up as a single.. Any ideas on what I've
messed up?

Element:
                Use-Case #1
                Use-Case #2

Object: TextCollector new "<-0x53b6698>" error: Invalid argument Transcript: must be a Boolean
SystemExceptions.MustBeBoolean(Exception)>>signal (ExcHandling.st:254)
SystemExceptions.MustBeBoolean class(SystemExceptions.WrongClass class)>>signalOn:mustBe: (SysExcept.st:805)
SystemExceptions.MustBeBoolean class>>signalOn: (SysExcept.st:881)
TextCollector(Object)>>mustBeBoolean (Object.st:1399)
[] in Array(Iterable)>>detect:ifNone: (Iterable.st:107)
Array(SequenceableCollection)>>do: (SeqCollect.st:812)
Array(Iterable)>>detect:ifNone: (Iterable.st:108)
Array(Iterable)>>detect: (Iterable.st:172)






reply via email to

[Prev in Thread] Current Thread [Next in Thread]