Is XpathExtract working, and how should it be set-up and used?
Im trying to extract a tag value from an xml document into an attribute to the document I have tried to use both the simple and the xml configuration setup but I never get any value from the added attribute.
Regards, Stefan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
<stage-inst>
<stage-name>getDocRunDate</stage-name>
<stage-desc>Extracts the date of this daily report</stage-desc>
<stage-type>XpathExtract</stage-type>
<option>
<option-name>XPath</option-name>
<option-value></option-value>
<sub-option>
<option-name>document_date</option-name>
<option-value>/Procedures[1]/Procedure[1]/Date/text()</option-value>
</sub-option>
</option>
</stage-inst>
Sherman answered you.
When you use XpathExtact, you need to specify one or more attributes that will contain result of XPath expression.
In case of properties files configuration you should use syntax:
stageName.XPath.attributeName=XPath expression
In case of XML config files use suboptions like in Sherman's code.
Dejan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2003-10-28
Thanks Sherman and Dejan!
You put me on the right track and I finally got what I wanted using this config:
Is XpathExtract working, and how should it be set-up and used?
Im trying to extract a tag value from an xml document into an attribute to the document I have tried to use both the simple and the xml configuration setup but I never get any value from the added attribute.
Regards, Stefan
Can you post here your pipeline configuration
Dejan
Here is the "config.property" file.
entryStage=filen
filen.stageType=XpathExtract
filen.nextStage=transform
filen.XPath=/Envelope/Payload/MessageMetaData/DocumentInfo/LogInfo
transform.stageType=XslTransform
transform.nextStage=writer
transform.transformationFile=c:/java/babeldoc-bin-1.2.0-RC2/stla/vonpluring/data/StripEnv.xsl
writer.stageType=FileWriter
writer.nextStage=null
writer.outputFile=c:/tmp/out/TST${document.get('LogInfo')}.xml
/Stefan
I use XML properties files, so I do things like:
<stage-inst>
<stage-name>getDocRunDate</stage-name>
<stage-desc>Extracts the date of this daily report</stage-desc>
<stage-type>XpathExtract</stage-type>
<option>
<option-name>XPath</option-name>
<option-value></option-value>
<sub-option>
<option-name>document_date</option-name>
<option-value>/Procedures[1]/Procedure[1]/Date/text()</option-value>
</sub-option>
</option>
</stage-inst>
but I think you want:
filen.stageType=XpathExtract
filen.nextStage=transform
filen.XPath.LogInfo=/Envelope/Payload/MessageMetaData/DocumentInfo/LogInfo
Sherman answered you.
When you use XpathExtact, you need to specify one or more attributes that will contain result of XPath expression.
In case of properties files configuration you should use syntax:
stageName.XPath.attributeName=XPath expression
In case of XML config files use suboptions like in Sherman's code.
Dejan
Thanks Sherman and Dejan!
You put me on the right track and I finally got what I wanted using this config:
<option>
<option-name>XPath</option-name>
<option-value/>
<sub-option>
<option-name>LogInfo</option-name>
<option-value>string(/Envelope/Payload/MessageMetaData/DocumentInfo/LogInfo)</option-value>
</sub-option>
</option>
</stage-inst>
<stage-inst>
<stage-name>transform</stage-name>
<stage-desc>this transforms stuff</stage-desc>
<stage-type>XslTransform</stage-type>
<option>