Injecting DOM
The final task in providing a concrete GxApplication class is to implement the newProcessingContext method on a derived class. You choose the tree, atomic values, metadata and symbols that your application will use. In many cases you can use an off-the-shelf processing context class, but you can also assemble or build your own.
If you are going to use gXML with
org.w3c.dom.Node, you have choices for the atomic values that your system will use as well as the metadata implementation. This example uses atomic values that are mostly Java wrapper types and the reference sequence type implementation,
SmSequenceType.
001 package org.gxml.book.parsing; 002 003 import org.gxml.sa.GxMetaBridge; 004 import org.gxml.sa.GxNameBridge; 005 import org.gxml.sa.mutable.GxApplicationMutable; 006 import org.gxml.sa.mutable.GxProcessingContextMutable; 007 import org.gxml.xs.SmMetaBridge; 008 import org.gxml.xs.SmSequenceType; 009 import org.w3c.dom.Node; 010 011 import com.tibco.gxml.sa.api.common.datatype.StringNameBridge; 012 import com.tibco.gxml.sa.common.atom.AtomBridge; 013 import com.tibco.gxml.sa.common.helpers.GxMetaBridgeOnSmMetaBridgeAdapter; 014 import com.tibco.gxml.sa.common.helpers.SmAtomBridgeOnGxAtomBridgeAdapter; 015 import com.tibco.gxml.sa.xdm.dom.DomProcessingContext; 016 import com.tibco.gxml.xs.SmMetaBridgeFactory; 017 018 /** 019 * Demonstration of constructing a concrete GxApplication(Mutable) implementation using the DOM processing context. 020 */ 021 public final class DomValidatingParsingSample extends BookValidatingParsingSample<Object, Object, Node, Object, String, SmSequenceType<Object, String>, Object> implements GxApplicationMutable<Object, Object, Node, Object, String, SmSequenceType<Object, String>, Object> 022 { 023 public final GxProcessingContextMutable<Object, Object, Node, Object, String, SmSequenceType<Object, String>, Object> newProcessingContext() 024 { 025 // The name bridge is created along with the processing context for maximum concurrency. 026 final GxNameBridge<String> nameBridge = new StringNameBridge(); 027 final AtomBridge<String> atomBridge = new AtomBridge<String>(nameBridge); 028 final SmMetaBridge<Object, String> cache = new SmMetaBridgeFactory<Object, String>(new SmAtomBridgeOnGxAtomBridgeAdapter<Object, String>(atomBridge)).newMetaBridge(); 029 final GxMetaBridge<Object, String, SmSequenceType<Object, String>> metaBridge = new GxMetaBridgeOnSmMetaBridgeAdapter<Object, String>(cache, atomBridge); 030 031 final DomProcessingContext<Object, SmSequenceType<Object, String>> pcx = new DomProcessingContext<Object, SmSequenceType<Object, String>> (this, metaBridge, cache); 032 033 // Set the "owning" processing context on the atom bridge. 034 atomBridge.setProcessingContext(pcx); 035 036 // Return the newly constructed processing context. 037 return pcx; 038 } 039 }
Copyright © 2022. Cloud Software Group, Inc. All Rights Reserved.