XML Processing

[Previous] [Next]

OmniMark processes XML (and SGML) in a streaming manner. The XML data is streamed from its source into the parser. Structural features, such as elements, fire markup rules. Data content is streamed directly to current output unless intercepted or redirected by your program. The OmniMark actions do xml-parse and do sgml-parse direct the input to the markup processor. For example, the following code fragment sends a file named Myfile.xml to the XML parser of the markup processor:

 do xml-parse instance scan file "Myfile.xml" output "%c" done 

When you process markup, you must deal with every level of nesting in the markup. Each element has content that can include other elements. When an element is encountered, you have to deal with three aspects: the start of the element, the content of the element, and the end of the element. To give you the opportunity to decide how and when to deal with the element content, markup processing stalls at each element. You need to explicitly get it going again.

How do you continue parsing? The OmniMark escape sequence %c causes parsing to continue. Think of it as equivalent to continue xml-parse. Since you will always want to continue parsing while generating output appropriate to the current element, the parse continuation operator takes the form of a text escape %c that you can drop into a text string. A do xml-parse simply sets up the parser in the appropriate initial state to process the input it receives. To actually start parsing, you must output the parse continuation operator %c:

 do xml-parse document scan file "daffy.xml" output "Beginning %c End") done 

Each markup rule must output the parse continuation operator %c or its alternative, suppress, which continues parsing but suppresses the output of the parsed content. For obvious reasons, you cannot use %c or suppress more than once in a markup rule. Don't fall into the trap of thinking that %c stands for the content of an element. It does not. It is an instruction to continue parsing that content. Any output that appears with%c is either data content streamed directly to current output or output produced by the rules that fire while parsing element content.



XML and SOAP Programming for BizTalk Servers
XML and SOAP Programming for BizTalk(TM) Servers (DV-MPS Programming)
ISBN: 0735611262
EAN: 2147483647
Year: 2000
Pages: 150

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net