<!ELEMENT InfopipeSpec (InputDTD?, OutputDTD?, Method+)>
<!ATTLIST InfopipeSpec id CDATA #REQUIRED>
<!ELEMENT InputDTD (#PCDATA)>
<!ELEMENT OutputDTD (#PCDATA)>
<!ELEMENT Method (InArgs?, InoutArgs?, OutArgs?)>
<!ATTLIST Method id CDATA #REQUIRED>
<!ATTLIST Method match CDATA #REQUIRED>
<!ELEMENT InArgs (Arg+)>
<!ATTLIST InArgs id CDATA #REQUIRED>
<!ELEMENT InoutArgs (Arg+)>
<!ATTLIST InoutArgs id CDATA #REQUIRED>
<!ELEMENT OutArgs (Arg+)>
<!ATTLIST OutArgs id CDATA #REQUIRED>
<!ELEMENT Arg (#PCDATA)>
<!ATTLIST Arg type CDATA #REQUIRED>
<!ATTLIST Arg id CDATA #REQUIRED>
The following example of the Jabber messaging stream is not exactly the same as the authors use.
<stream:stream to="infosphere.org" xmlns="jabber:client" ...>
<iq type="set" id="1">
<query xmlns="jabber:iq:auth">
<username>morimori</username>
<digest>2E4E..fadjkf;asd...</digest> <!-- encoded password -->
<resource>JIM-J/Palm</resource>
</query>
</iq>
<presence/>
<message to="chikako@infosphere.org">
<subject>Testing</subject>
<body>This is a test message...</body>
</message>
... continued ...
Here is the XML representation of the Infopipe Spec for the Image Converter Infopipe
<?xml version="1.0"?>
<!DOCTYPE InfopipeSpec SYSTEM "InfopipeSpec.dtd">
<InfopipeSpec id="ImageConverter">
<Method id="convert" match="image">
<InoutArgs id="Inout">
<Arg type="text" id="contentType">Content-Type/text()</Arg>
<Arg type="text" id="contentTransferEncoding">Content-Transfer-Encoding/text()</Arg>
<Arg type="text" id="contentBody">Content-Body/text()</Arg>
</InoutArgs>
</Method>
</InfopipeSpec>
The following is the main part of ImageConverter.java.
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class ImageConverter {
/** inout arguments for convert() */
public class Inout {
public String contentType;
public String contentTransferEncoding;
public String contentBody;
}
/** method convert */
public void convert(Inout inout) throws ImageConverterException {
}
}
The following is the main part of ImageConverterException.java.
public class ImageConverterException extends Exception {
ImageConverterException(String msg) {
super("ImageConverterException: " + msg);
}
}
The following is the part of ImageConverterStub.java.
document = parser.getDocument();
Node root = document.getDocumentElement();
Node node = null;
NodeList nl = null;
try {
nl = XPathAPI.selectNodeList(root, "image");
ImageConverter.Inout imageConverter_Inout = imageConverter.new Inout();
for (int i = 0; i < nl.getLength(); i ++) {
node = XPathAPI.selectSingleNode(nl.item(i), "Content-Type/text()");
if (node != null) {
if (node.getNodeType() == Node.TEXT_NODE) {
imageConverter_Inout.contentType = node.getNodeValue();
} else if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
imageConverter_Inout.contentType = ((Attr)node).getValue();
} else {
throw new ImageConverterException("this node type cannot be treated...");
... continued ...