× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



xml document:
<?xml version="1.0" encoding="ISO-8859-15" ?>

<kundenstamm>
<nummer>358</nummer>
<name>Dirk Rossmann GmbH</name>
<anschrift>
<plz>32425</plz>
<ort>Minden</ort>
<strasse>Königswall 314</strasse>
</anschrift>
</kundenstamm>


rpg program:
/copy QCPYSRC,RPGHEADER
HDEBUG(*YES)
*---------------------------------------------------------------
* Prototypen
*---------------------------------------------------------------
D xmlHandler PR 10I 0
D commArea likeds(info)
D event 10I 0 value
D string * value
D stringLen 20I 0 value
D exceptionId 10I 0 value

*---------------------------------------------------------------
* Variablen
*---------------------------------------------------------------
D info DS
D wert 100A varying
*

* Programmfehlerdatenstruktur

*

DProgramErrDS SDS

D Routine *ROUTINE

D Status *STATUS

D Parameter *PARMS

D Prozedur *PROC
/free
xml-sax %handler(xmlHandler : info)
%xml('/usr/share/docs/xml-test/xml-test-1.xml' :
'doc=file');

*inlr = *on;
return;

begsr *PSSR;
dsply 'Error:';
dsply Routine;
dsply Status;
dsply Parameter;
dsply Prozedur;
endsr;
/end-free



P xmlHandler B
D PI 10I 0
D commArea likeds(info)
D event 10I 0 value
D string * value
D stringLen 20I 0 value
D exceptionId 10I 0 value
*
D value S 1000A based(string)
D dspval S 52A
D retVal S 10I 0
/free
select;
when (event = *XML_START_DOCUMENT);
dsply 'Start ...';

when (event = *XML_END_DOCUMENT);
dsply 'Ende ...';

when (event = *XML_CHARS);
dspval = 'Zeichen: ' + %subst(value : 1 : stringLen);
dsply dspval;

endsl;

return retVal;
/end-free
P E



output:

call xmlsax01
DSPLY Start ...
DSPLY Zeichen: 
DSPLY Zeichen: 358
DSPLY Zeichen: 
DSPLY Zeichen: Dirk Rossmann GmbH
DSPLY Zeichen: 
DSPLY Zeichen: 
DSPLY Zeichen: 32425
DSPLY Zeichen: 
DSPLY Zeichen: Minden
DSPLY Zeichen: 
DSPLY Zeichen: Königswall 314
DSPLY Zeichen: 
DSPLY Zeichen: 
DSPLY Ende ...


hope it helps and gives you (and me) some clues.

thanx in advance (till tomorrow).

mihael knezevic


-----Ursprüngliche Nachricht-----
Von: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] Im
Auftrag von albartell
Gesendet: Mittwoch, 11. April 2007 15:38
An: 'RPG programming on the AS400 / iSeries'
Betreff: RE: XML-SAX and ignore whitespace

Could you post an full program example of what you are doing so we can get
the big picture? That might get you an answer quicker than anything.

Note that you can post the code at http://code.midrange.com and copy/paste
your link back to the list.

Aaron Bartell
http://mowyourlawn.com

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Knezevic, Mihael
Sent: Wednesday, April 11, 2007 8:21 AM
To: RPG programming on the AS400 / iSeries
Subject: AW: XML-SAX and ignore whitespace

but the trim option is only for XML-INTO. XML-SAX will fail already at
compilation.

i just check the hex values of the whitespaces, nothing unusual: 25
(linefeed), 05 (tab).

-----Ursprüngliche Nachricht-----
Von: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] Im
Auftrag von albartell
Gesendet: Mittwoch, 11. April 2007 14:15
An: 'RPG programming on the AS400 / iSeries'
Betreff: RE: XML-SAX and ignore whitespace

Below is the RPG Manual's definition of it. Looks like by default it SHOULD
trim whitespace (i.e. blanks, newlines, tabs). Interesting how they put
'etc.' in there vs. literally list everything it actually IS going to trim.
If you aren't getting the expected results when specifying trim=all or when
not specifying trim then I would say there is either a compiler bug or your
newlines aren't the standard newline characters that the XML parser is
expecting.

RPG Manual
trim (default all)
The trim option specifies whether whitespace (blanks, newlines, tabs
etc.) should be trimmed from text data before the data is assigned to RPG
variables

* all indicates that before text content is assigned to the RPG
character or UCS-2 variable, the following steps will be done:
1. Leading and trailing whitespace will be trimmed completely
from text content
2. Strings of interior whitespace in the text content will be
reduced to a single blank
* none indicates that no whitespace will be trimmed from text
content. This option will have the best performance, but it should only be
used if the whitespace is wanted, or if the XML data is known to contain no
unwanted whitespace, or if the RPG program is going to handle the removal of
the whitespace itself.

Notes:

1. Whitespace includes blank, tab, end-of-line, carriage-return, and
line-feed.
2. This option applies only to XML data that is to be assigned to
character and UCS-2 RPG variables. Trimming of whitespace is always done for
other data types.
3. This option is mainly provided for XML data from files, but it
also applies to XML data from a variable.
4. Whitespace between XML elements is always ignored. The trim option
controls the whitespace within text content of elements and attributes.

HTH,
Aaron Bartell


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Knezevic, Mihael
Sent: Wednesday, April 11, 2007 6:55 AM
To: RPG programming on the AS400 / iSeries
Subject: AW: XML-SAX and ignore whitespace

ok. i forgot to mention that i used the operationscode XML-SAX for parsing
and i don't want to trigger a call for my handler for a whitespace.

any ideas?

mihael

-----Ursprüngliche Nachricht-----
Von: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] Im
Auftrag von albartell
Gesendet: Mittwoch, 11. April 2007 13:50
An: 'RPG programming on the AS400 / iSeries'
Betreff: RE: XML-SAX and ignore whitespace

An XML element can be what's called "mixed content". Traditionally we think
of XML element being one of two things:

1) Exists to hold data <xmltag>mydata</xmltag>
2) Exists to be a parent to other elements <xmltag><child></child></xmltag>

The third way to think of them is by way of what's called "mixed content"
meaning that a tag acts as both #1 and #2 above:

<xmltag>mydata<child></child></xmltag>

In my work with XML I don't think I EVER see mixed content used except for
cheesy examples showing how you *might* use it. In the end I think mixed
content causes more heartache/problems than anything because a lot of XML
isn't formatted in a flat stream as I showed above, but is instead formatted
as such:

<xmltag>
<child></child>
<xmltag>

When all the XML is in a flat line (i.e. no carriage return line feeds) then
you can expect to have a single 'element content' event. When XML is
formatted on multiple lines (i.e. one element per line with a carriage
return line feed after each) then you will get many more 'element content'
events when parsing for all parent tags. The above for instance will
generate a 'element content' event for <xmltag> in regards to the carriage
return line feed plus preceding spaces to <child> element. Then another
<xmltag> 'element content' event will be triggered for the carriage return
line feed after the </child> element closure.

HTH,
Aaron Bartell
http://mowyourlawn.com


-----Original Message-----
From: rpg400-l-bounces+albartell=gmail.com@xxxxxxxxxxxx
[mailto:rpg400-l-bounces+albartell=gmail.com@xxxxxxxxxxxx] On Behalf Of
Knezevic, Mihael
Sent: Wednesday, April 11, 2007 6:30 AM
To: RPG programming on the AS400 / iSeries
Subject: XML-SAX and ignore whitespace

hi,

i'm currently playing around with xml-sax. i got a xml file and it is read
with xml-sax with no errors. but for the whitespaces like newlines and tabs
are included the handler procedure is called. with xml-into i can say
"trim=all" but xml-sax won't accept that. is there some other keyword or
workaround? i just don't want to process every newline or tab.

thanx in advance

mihael knezevic
--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or
change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.

--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or
change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.


--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or
change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.