I've been having an issue with XML rules where, I can load the rules file and the Digester instance is created, but when I go to process my file zero rules are found.  I create the same configuration programmatically and the file is processed correctly.  I have attached my digester-rules XML and a sample configuration file.

I've checked and double checked to make sure the patterns were correct in the digester rules file, but I can't seem to find what's wrong.



Thanks,
Brad
<?xml version="1.0" encoding="UTF-8"?>
<legacy-reader>

	<!-- include file="/some/path/to/some/file.xml" / -->
<!-- 
	<datatypes>
		<datatype name="integer"
				classname="net.joat.legacy.formats.IntegerFormat" />
		<datatype name="date" classname="net.joat.legacy.formats.DateFormat">
			<property name="pattern" value="yyyyMMdd" />
		</datatype>
	</datatypes>
-->
	<line-ids>
		<line-id name="headerId" regex="^1TRANS">
			<token name="headerToken" start="1" end="6" />
		</line-id>
	</line-ids>
	<line-formats>
		<line-format name="autorouteHeader">
			<token name="applicationDate" start="7" end="14" />
			<token name="productDescription" start="20" end="39" />
			<token name="multiCycleTransCounter" start="44" end="45" />
			<token name="duplicateIndicator" start="46" />
			<token name="productId" start="47" end="54"
					filling="0" align="right"/>
			<token name="applicationMultiCycleCount" start="55" end="56"
					filling="0" align="right" />
			<token name="recipientId" start="57" end="63" />
			<token name="filler.zeroes.1" start="64" end="66" filling="0" />
			<token name="recordCount" start="67" end="73" filling="0"
					align="right" />
			<token name="senderId" start="74" end="77" />
			<token name="constantField" start="78" end="80" />
		</line-format>
	</line-formats>
	<records>
		<record line-id="headerId" classname="net.joat.legacy.config.AutoRoute">
			<line order="1" id-value="1TRANS" format="autorouteHeader" />
		</record>
	</records>
</legacy-reader>
<?xml version="1.0" encoding="UTF-8"?>
<digester-rules>

	<pattern value="legacy-reader">

		<!-- the first components to register are the datatypes. -->
		<pattern value="datatypes">
			<pattern value="datatype">
					
				<!-- 
				  - make the call-method-rule the first rule to be executed.
				  - since this rule is not executed until the end of the
				  - datatype tag, it needs to be first so the top object is
				  - not popped from the stack and lost.
				  -->
				<call-method-rule
						targetOffset="1" methodname="addType" paramcount="2"
						paramtypes="java.lang.String,net.joat.legacy.Type" />
	
				<!--
				  - create an instance of the datatype before registering the
				  - parameters for the method call above.  this way we ensure
				  - the datatype object is at the top of the stack prior to the
				  - registration of the object as a parameter.
				  -->
				<object-create-rule
						classname="net.joat.legacy.Type" attrname="classname" />
						
				<!--
				  - any number of properties may be assigned to customize the
				  - datatype.  the name attribute of the property tag defines the
				  - name of the property to be set and the value attribute is the
				  - new value of the property.
				  -->
				<pattern name="property">
					<set-property-rule name="name" value="value" />
				</pattern>
	
				<!-- 
				  - register the parameters for the method call.  the first
				  - parameter is the name of the datatype specified in the
				  - attribute "name".  the next parameter is the datatype
				  - object created above.
				  -->
				<call-param-rule paramnumber="0" attrname="name" />
				<call-param-rule paramnumber="1" from-stack="true" />
			</pattern>
		</pattern>

		<!-- 
		  - there are two places the net.joat.legacy.LineFormat objects are
		  - created.  the first place is for line ids.  the line formats for
		  - the line ids configure the structure of the unique identifier for
		  - the line structure.
		  - the second place LineFormat objects are created is for the line
		  - structure itself.  these are associated with line ids later on
		  - with the creation of net.joat.legacy.Line objects.
		  -->
		  
		<!-- we need to create the LineFormat objects for the line ids. -->
		<pattern value="line-ids">
			<pattern value="line-id">
	
				<call-method-rule
						targetOffset="1" methodname="addLineIdFormat"
						paramcount="1" paramtypes="net.joat.legacy.LineIdFormat" />
			
				<!-- 
				  - create the actual LineIdFormat object.  this will allow us to
				  - add tokens later on, and to set the properties of the line
				  - format.  the tokens are added using the pattern "*/token" since
				  - they can be defined for line ids and line formats.
				  -->
				<object-create-rule classname="net.joat.legacy.LineIdFormat" />
				<set-properties-rule />
			
				<call-param-rule paramnumber="0" from-stack="true" />
			</pattern>
		</pattern>
		
		<!-- we need to create the LineFormat objects for the line formats. -->
		<pattern value="line-formats">
			<pattern value="line-format">
	
				<call-method-rule
						targetOffset="1" methodname="addLineFormat" paramcount="1"
						paramtypes="net.joat.legacy.LineFormat" />
			
				<!-- 
				  - create the actual LineFormat object.  this will allow us to add
				  - tokens later on, and to set the properties of the line format.
				  - the tokens are added using the pattern "*/token" since they can
				  - be defined for line ids and line formats.
				  -->
				<object-create-rule classname="net.joat.legacy.LineFormat" />
				<set-properties-rule />
			
				<call-param-rule paramnumber="0" from-stack="true" />
			</pattern>
		</pattern>
		
		<!-- 
		  - now we can create the token, set its properties and add it to
		  - the line id or line format.
		  -->
		<pattern value="*/token">
			<object-create-rule classname="net.joat.legacy.Token" />
			<set-properties-rule>
				
				<!-- 
				  - we need to define some aliases because the attribute
				  - names do not match up with the property names.
				  -->
				<alias attr-name="start" prop-name="startIndex" />
				<alias attr-name="end" prop-name="endIndex" />
				<alias attr-name="align" prop-name="alignment" />
			</set-properties-rule>
			<set-next-rule
					methodname="addToken" type="net.joat.legacy.Token" />
		</pattern>
		
		<!-- 
		  - to tie everything together we need to register the records.  records
		  - are a collection of lines.  the lines are a line-id whose values
		  - have been assigned and a line format.  the record then uses the
		  - line id to find a the line to parse and uses the configured
		  - line format to parse the legacy data line.
		  -->
		<pattern value="records">
			<pattern value="record">
			
				<object-create-rule classname="net.joat.legacy.Record" />
				<set-properties-rule>
					<alias attr-name="line-id" prop-name="idFormat" />
					<alias attr-name="classname" prop-name="dataClass" />
				</set-properties-rule>
				
				<!-- a listener may be assigned to execute on read/write events. -->
				<pattern value="listener">
					<object-create-rule
							classname="net.joat.legacy.event.LineListener"
							attrname="classname" />
					<set-next-rule 
							methodname="setLineListener"
							type="net.joat.legacy.event.LineListener" />
				</pattern>
				
				<!-- add the lines to the record. -->
				<pattern value="line">
					<object-create-rule	classname="net.joat.legacy.Line" />
					<set-properties-rule />
				</pattern>
				
				<!--
				  - this is a custom class which adds custom rules to process the
				  - 'id-value' attribute for the line element.  it's added here
				  - because the class specifies the "line" element in the code when
				  - adding the custom rule.
				  -->
				<include class="net.joat.legacy.config.LineIdSetterRulesSource" />
				
				<set-next-rule
						methodname="addRecord" paramtype="net.joat.legacy.Record" />
			</pattern>
		</pattern>
	</pattern>
</digester-rules>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to