x -- c-addr u | 0Data x is the same as the first parameter during calling of the word xis-set-reader. For reading from files this is normally the file descriptor. The word returns, if successful, the read data in c-addr u. The xis-read word returns the parsed xml token with the following varying stack parameters:
xis.error -- xis.done -- xis.start-xml -- c-addr1 u1 .. c-addrn un n = Return n attribute names with their value xis.comment -- c-addr u = Return the comment xis.text -- c-addr u = Return the normal text xis.start-tag -- c-addr1 u1 .. c-addrn un n c-addr u = Return the tag name and n attributes with their value xis.end-tag -- c-addr u = Return the tag name xis.empty-element -- c-addr1 u1 .. c-addrn un n c-addr u = Return the tag name and n attributes with their value xis.cdata -- c-addr u = Return the CDATA section text xis.proc-instr -- c-addr1 u1 .. c-addrn un n c-addr u = Return the target name and n attributes with their value xis.internal-dtd -- c-addr1 u1 c-addr2 u2 = Return the DTD name c-addr2 u2 and markup c-addr1 u1 xis.public-dtd -- c-addr1 u1 c-addr2 u2 c-addr3 u3 c-addr4 u4 = Return the DTD name, the markup, the system-id and public-id xis.system-dtd -- c-addr1 u1 c-addr2 u2 c-addr3 u3 = Return the DTD name, the markup and the system-id
\ ==============================================================================
\
\ xis_expl - the text input stream example in the ffl
\
\ Copyright (C) 2007 Dick van Oudheusden
\
\ This library is free software; you can redistribute it and/or
\ modify it under the terms of the GNU General Public
\ License as published by the Free Software Foundation; either
\ version 2 of the License, or (at your option) any later version.
\
\ This library is distributed in the hope that it will be useful,
\ but WITHOUT ANY WARRANTY; without even the implied warranty of
\ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\ General Public License for more details.
\
\ You should have received a copy of the GNU General Public
\ License along with this library; if not, write to the Free
\ Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
\
\ ==============================================================================
\
\ $Date: 2008-11-16 18:55:14 $ $Revision: 1.5 $
\
\ ==============================================================================
include ffl/xis.fs
\ Example: Read a XML/HTML file
\ Create a XML/HTML input stream on the heap
xis-new value xis1
\ Setup the reader callback word for reading from file
: file-reader ( fileid -- c-addr u | 0 )
pad 64 rot read-file throw
dup IF
pad swap
THEN
;
s" test.xml" r/o open-file throw value xis.file \ Open the file
xis.file ' file-reader xis1 xis-set-reader \ Use the xml reader with a file
true xis1 xis-strip! \ Strip leading and trailing whitespace in the text
: file-parse ( -- = Parse the xml file )
BEGIN
xis1 xis-read \ Read the next token from the file
dup xis.error <> over xis.done <> AND \ Done when ready or error
WHILE
xis+dump-read-parameters \ Dump the next token with its parameters
REPEAT
xis.error = IF
." Error parsing the file." cr
ELSE
." File succesfully parsed." cr
THEN
;
\ Parse the file
file-parse
\ Done, close the file
xis.file close-file throw
\ Free the stream from the heap
xis1 xis-free
Generated by fsdocgen 0.1.0