camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > Jing
Date Mon, 29 Mar 2010 01:24:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
     <h2><a href="http://cwiki.apache.org/confluence/display/CAMEL/Jing">Jing</a></h2>
     <h4>Page <b>edited</b> by             <a href="http://cwiki.apache.org/confluence/display/~njiang">willem
jiang</a>
    </h4>
     
          <br/>
     <div class="notificationGreySide">
         <h2><a name="Jing-JingComponent"></a>Jing Component</h2>

<p>The Jing component uses the <a href="http://www.thaiopensource.com/relaxng/jing.html"
rel="nofollow">Jing Library</a> to perform XML validation of the message body using
either</p>

<ul>
	<li><a href="http://relaxng.org/" rel="nofollow">RelaxNG XML Syntax</a></li>
	<li><a href="http://relaxng.org/compact-tutorial-20030326.html" rel="nofollow">RelaxNG
Compact Syntax</a></li>
</ul>


<p>Maven users will need to add the following dependency to their <tt>pom.xml</tt>
for this component:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
&lt;dependency&gt;
    &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
    &lt;artifactId&gt;camel-jing&lt;/artifactId&gt;
    &lt;version&gt;x.x.x&lt;/version&gt;
    &lt;!-- use the same version as your Camel core version --&gt;
&lt;/dependency&gt;
</pre>
</div></div>

<p>Note that the <a href="/confluence/display/CAMEL/MSV" title="MSV">MSV</a>
component can also support RelaxNG XML syntax.</p>

<h3><a name="Jing-URIformat"></a>URI format</h3>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
rng:someLocalOrRemoteResource
rnc:someLocalOrRemoteResource
</pre>
</div></div>

<p>Where <b>rng</b> means use the <a href="http://relaxng.org/" rel="nofollow">RelaxNG
XML Syntax</a> whereas <b>rnc</b> means use <a href="http://relaxng.org/compact-tutorial-20030326.html"
rel="nofollow">RelaxNG Compact Syntax</a>. The following examples show possible URI
values</p>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>Example</th>
<th class='confluenceTh'>Description</th>
</tr>
<tr>
<td class='confluenceTd'>rng:foo/bar.rng</td>
<td class='confluenceTd'> References the XML file <b>foo/bar.rng</b> on
the classpath </td>
</tr>
<tr>
<td class='confluenceTd'>rnc:<a href="http://foo.com/bar.rnc" rel="nofollow">http://foo.com/bar.rnc</a></td>
<td class='confluenceTd'> References the RelaxNG Compact Syntax file from the URL, <a
href="http://foo.com/bar.rnc" rel="nofollow">http://foo.com/bar.rnc</a></td>
</tr>
</tbody></table>

<p>You can append query options to the URI in the following format, <tt>?option=value&amp;option=value&amp;...</tt></p>

<h3><a name="Jing-Options"></a>Options</h3>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Option </th>
<th class='confluenceTh'> Default </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>useDom</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> <b>Camel 2.0:</b> Specifies whether DOMSource/DOMResult
or SaxSource/SaxResult should be used by the validator. </td>
</tr>
</tbody></table>

<h3><a name="Jing-Example"></a>Example</h3>

<p>The following <a href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-jing/src/test/resources/org/apache/camel/component/validator/jing/rnc-context.xml"
rel="nofollow">example</a> shows how to configure a route from the endpoint <b>direct:start</b>
which then goes to one of two endpoints, either <b>mock:valid</b> or <b>mock:invalid</b>
based on whether or not the XML matches the given <a href="http://relaxng.org/compact-tutorial-20030326.html"
rel="nofollow">RelaxNG Compact Syntax</a> schema (which is supplied on the classpath).</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml"><span class="code-tag">&lt;camelContext xmlns=<span
class="code-quote">"http://camel.apache.org/schema/spring"</span>&gt;</span>
    <span class="code-tag">&lt;route&gt;</span>
        <span class="code-tag">&lt;from uri=<span class="code-quote">"direct:start"</span>/&gt;</span>
        <span class="code-tag">&lt;doTry&gt;</span>
            <span class="code-tag">&lt;to uri=<span class="code-quote">"rnc:org/apache/camel/component/validator/jing/schema.rnc"</span>/&gt;</span>
            <span class="code-tag">&lt;to uri=<span class="code-quote">"mock:valid"</span>/&gt;</span>

            <span class="code-tag">&lt;doCatch&gt;</span>
                <span class="code-tag">&lt;exception&gt;</span>org.apache.camel.ValidationException<span
class="code-tag">&lt;/exception&gt;</span>
                <span class="code-tag">&lt;to uri=<span class="code-quote">"mock:invalid"</span>/&gt;</span>
            <span class="code-tag">&lt;/doCatch&gt;</span>
            <span class="code-tag">&lt;doFinally&gt;</span>
                <span class="code-tag">&lt;to uri=<span class="code-quote">"mock:finally"</span>/&gt;</span>
            <span class="code-tag">&lt;/doFinally&gt;</span>
        <span class="code-tag">&lt;/doTry&gt;</span>
    <span class="code-tag">&lt;/route&gt;</span>
<span class="code-tag">&lt;/camelContext&gt;</span>
</pre>
</div></div>

<h3><a name="Jing-SeeAlso"></a>See Also</h3>
<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring
Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting
Started</a></li>
</ul>

     </div>
     <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href="http://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
       </div>

       <a href="http://cwiki.apache.org/confluence/display/CAMEL/Jing">View Online</a>
       |
       <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=63295&revisedVersion=11&originalVersion=10">View
Change</a>
              |
       <a href="http://cwiki.apache.org/confluence/display/CAMEL/Jing?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message