I have this canonical structure:
<xsd:complexType name="Document">
<xsd:attribute name="ID" use="optional" type="cdpscm:IDDocument"/>
</xsd:complexType>
<xsd:element name="NationalID" type="cdpscm:NationalID"/>
<xsd:complexType name="NationalID">
<xsd:complexContent>
<xsd:extension base="cdpscm:Document">
<xsd:sequence>
<xsd:element name="Number"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:element name="Passaport" type="cdpscm:Passaport"/>
<xsd:complexType name="Passaport">
<xsd:complexContent>
<xsd:extension base="cdpscm:Document">
<xsd:sequence>
<xsd:element name="Number"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
Who calls my OSB service will cast if the document is a Passaport or a NationalID, but how I get the number value to pass to another service, for example, if I only have the Document element type which doesn't has the number element.
This is the supossed input:
<v24:Person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="v2:TouristPerson" ID="5772893">
<v2:Documents>
<v2:Document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="v2:Passport">
<v2:Number>03070</v2:Number>
</v2:Document>
</v2:Documents>
</v24:Person>
The real structure is more complex than this, so probably will need to know if I'm working with NationalID or Passaport, a Tourist or a Native Person.
Using Oracle 11g, Eclipse OEPE.
Thanks for the help!
Something like this should work.
declare namespace xsi = "http://www.w3.org/2001/XMLSchema-instance";
let $documents := $body//v24:Person/v2:Documents/v2:Document
for $passport in $documents[#xsi:type="v2:Passport"]
return data($passport/v2:Number)
(: similarly for national IDs :)
Related
I would like to turn this xml response into something more easily readable.
<?xml version="1.0" encoding="ISO-8859-1"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"/>
<soap:Body>
<executeResponse xmlns="urn:GCE">
<BusinessViewServiceexecuteOut xmlns="http://www.generix.fr/technicalframework/businesscomponent/applicationmodule/common" xmlns:ns2="http://www.generixgroup.com/processus/configuration/scheduler" xmlns:ns3="http://www.generix.fr/technicalframework/business/service/common">
<xmlpres><?xml version = '1.0' encoding = 'UTF-8'?> <VueTable type="View" name="Table" habctr="true" total_business_row="2" nbline="400" confNbline="400" numpage="1" nbpage="1">
<JTblView name="JTblView" type="ViewObject" maxfetchsize="999" maxfetchsizeexceeded="false">
<JTblViewRow current="true" type="ViewRow" index="1" business_row_index="1">
<Cletbl precision="6" type="VARCHAR" pk="true">
<business_data>N</business_data>
</Cletbl>
<Codtbl precision="6" type="VARCHAR" pk="true">
<business_data>001</business_data>
</Codtbl>
<Lib1 precision="30" type="VARCHAR">
<business_data>Non</business_data>
</Lib1>
<Lib2 precision="30" type="VARCHAR">
<business_data/>
</Lib2>
<Lir precision="10" type="VARCHAR">
<business_data>Non</business_data>
</Lir>
</JTblViewRow>
<JTblViewRow type="ViewRow" index="2" business_row_index="2">
<Cletbl precision="6" type="VARCHAR" pk="true">
<business_data>O</business_data>
</Cletbl>
<Codtbl precision="6" type="VARCHAR" pk="true">
<business_data>001</business_data>
</Codtbl>
<Lib1 precision="30" type="VARCHAR">
<business_data>Oui</business_data>
</Lib1>
<Lib2 precision="30" type="VARCHAR">
<business_data/>
</Lib2>
<Lir precision="10" type="VARCHAR">
<business_data>Oui</business_data>
</Lir>
</JTblViewRow>
</JTblView>
</VueTable></xmlpres>
</BusinessViewServiceexecuteOut>
</executeResponse>
</soap:Body></soap:Envelope>
At least if I could extract what's in the value of "xmlpres", the better I could do:
<table><row><code></code><libelle></libelle/></row></table>
To then turn it into a json response but I can't see ... I just get all the output or in json stream but with everything , which is not usable.
Create an out-mediation sequence with the following content and attach it to the respective API and try out the scenario. This is to extract the xmlpres content and send that as the response to the client
<?xml version="1.0" encoding="UTF-8"?>
<sequence xmlns="http://ws.apache.org/ns/synapse" name="out-sequence">
<!-- extract the xmlpres content and store as OM element -->
<property name="XMLBody"
expression="$body//soap:Body//generic:xmlpres"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:gce="urn:GCE"
xmlns:generic="http://www.generix.fr/technicalframework/businesscomponent/applicationmodule/common" type="OM" />
<!-- pass the extracted property as response body -->
<enrich>
<source type="property" property="XMLBody" />
<target type="body" />
</enrich>
</sequence>
Hope this helps you to extract and send the response accordingly.
I'm trying to take the version from version.sbt and and populate it to logback.xml's log appender's applicationVersion field.
version.sbt
version in ThisBuild := "0.4.63"
logback.xml
<configuration debug="true" scan="true" scanPeriod="60 seconds">
<appender name="ADP-MESSAGING" class="com.agoda.adp.messaging.logging.appenders.LogbackAppender">
<applicationName>MyApp</applicationName>
<applicationAssemblyName>myapp</applicationAssemblyName>
<applicationVersion>0.4.61</applicationVersion>
<!-- <applicationVersion>${application.version}</applicationVersion> -->
<apiKey>s234W##$WFW$#$#</apiKey>
<getCallerData>false</getCallerData>
</appender>
....
<root level="WARN">
<appender-ref ref="ADP-MESSAGING" />
<appender-ref ref="STDOUT" />
</root>
</configuration>
I tried by adding ${application.version}, ${version} but no success.
How can I do this?
Please share your thoughts.
Thanks
The values interpolated in a logback.xml file are simply Java system properties. All you have to do is add a value to your Java commandline defining the value you want:
// NOTE: This will only work when running through sbt. You'll have to
// append the same value to your startup scripts when running elsewhere.
javaOptions += "-Dapplication.version=" + version.value
With this flag, you should be able to interpolate the version in your XML file:
<applicationVersion>${application.version}</applicationVersion>
You can add logback PropertyDefiner implementation:
package org.mypackage
import ch.qos.logback.core.PropertyDefinerBase
class VersionPropertyDefiner extends PropertyDefinerBase {
override def getPropertyValue: String = BuildInfo.version
}
You will get autogenerated (managed) scala code BuildInfo.version if you use BuildInfoPlugin in your project build settings.
Then you can define and use variable in your logback.xml configuration:
<configuration debug="true" scan="true" scanPeriod="60 seconds">
<define name="appVersion" class="org.mypackage.VersionPropertyDefiner"/>
<appender name="ADP-MESSAGING" class="com.agoda.adp.messaging.logging.appenders.LogbackAppender">
<applicationName>MyApp</applicationName>
<applicationAssemblyName>myapp</applicationAssemblyName>
<applicationVersion>${appVersion}</applicationVersion>
<apiKey>s234W##$WFW$#$#</apiKey>
<getCallerData>false</getCallerData>
</appender>
....
<root level="WARN">
<appender-ref ref="ADP-MESSAGING" />
<appender-ref ref="STDOUT" />
</root>
</configuration>
I have an XML like this.
<?xml version="1.0" encoding="UTF-8"?>
<doc>
<ticker> CSGN.VX </ticker>
<stockExchange> NYSE </stockExchange>
<stockDatas>
<stockData>
<date>2015-08-06</date>
<closingPrice>140</closingPrice>
</stockData>
<stockData>
<date>2015-08-07</date>
<closingPrice>140.25</closingPrice>
</stockData>
<stockData>
<date>2015-08-10</date>
<closingPrice>140.75</closingPrice>
</stockData>
</stockDatas>
</doc>
And I will be having similar XMLs for different companies around different years. Now I want to search for documents which have the ticker as CSGN.VX for a particular time duration, so I use this query.
xquery version "1.0-ml";
import module namespace search = "http://marklogic.com/appservices/search" at "/MarkLogic/appservices/search/search.xqy";
search:search(
'ticker:CSGN.VX AND (dateRange GE "2015-08-07" AND dateRange LE "2015-08-21")',
<options xmlns="http://marklogic.com/appservices/search">
<constraint name="dateRange">
<range type="xs:date" facet="false">
<element ns="" name="date"/>
</range>
</constraint>
<constraint name="ticker">
<range type="xs:string" >
<element ns="" name="ticker"/>
</range>
</constraint>
</options>)
Is there a way where along with the document search, I can also get the closingPrice average for that particular time duration?
I just got a solution but i have a further query, i was looking for a way to implement this using java client API of Marklogic so is there a way to implement search:parse and search:values using Java Client API
I know one way to implement this is through MarklogicXCC API but i wanted to know if there is a way through which these functions can be run using Client API
Provided you have a range index on closingPrice you should be able to do something like this:
xquery version "1.0-ml";
import module namespace search = "http://marklogic.com/appservices/search"at "/MarkLogic/appservices/search/search.xqy";
let $query :=
search:parse(
'ticker:CSGN.VX AND (dateRange GE "2015-08-07" AND dateRange LE "2015-08-21")',
<options xmlns="http://marklogic.com/appservices/search">
<constraint name="dateRange">
<range type="xs:date" facet="false">
<element ns="" name="date"/>
</range>
</constraint>
<constraint name="ticker">
<range type="xs:string" >
<element ns="" name="ticker"/>
</range>
</constraint>
</options>,
"search:query"
)
return
search:values(
'closingPrice',
<options xmlns="http://marklogic.com/appservices/search">
<values name="closingPrice">
<range type="xs:double">
<element ns="" name="closingPrice"/>
</range>
<aggregate apply="avg"/>
</values>
</options>,
$query
)
Note: I do recommend storing each stockData separately, otherwise the dateRange filter probably won't work as expected.
HTH!
I am facing this issue since couple of days.
My requirement is to execute a stored procedure and if data found run the orchestration every 10-15 min.
for that i using polling approach with Oracle.
I have below stored procedure,
create or replace procedure BTS_RAD_PollManageStateDOCAMD( p_rc out sys_refcursor) is
begin
for rec in (
SELECT * FROM RAD_BTS_MANAGE_DOCAMS
WHERE MESSAGE_STATE='CREATED')
loop
dbms_output.put_line(
rec.CORRELATION_ID || ',' || rec.MESSAGE_KEY || ',' ||rec.MESSAGE_FILENAME || ',' ||rec.MESSAGE_ROOTNODE
||',' ||rec.MESSAGE_ELIMINATEDFLAG || ',' ||rec.MESSAGE_CONTENT || ',' ||rec.MESSAGE_STATE );
end loop;
end;
I have genarated the below schemas via consume adapter services method.
I got three schemas
OracleDBBindingGenericOperation.xsd
OracleDBBindingRADAR.PollingProcedure.xsd
OracleDBBindingRADAR.Procedure.xsd
in that i am using the
OracleDBBindingRADAR.PollingProcedure.xsd as my message in orch.
<?xml version="1.0" encoding="utf-16" ?>
- <xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns:ns3="http://Microsoft.LobServices.OracleDB/2007/03" elementFormDefault="qualified" targetNamespace="http://Microsoft.LobServices.OracleDB/2007/03/RADAR/PollingProcedure" version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import schemaLocation=".\OracleDBBindingGenericOperation.xsd" namespace="http://Microsoft.LobServices.OracleDB/2007/03" />
- <xs:annotation>
- <xs:appinfo>
<fileNameHint xmlns="http://schemas.microsoft.com/servicemodel/adapters/metadata/xsd">RADAR.PollingProcedure</fileNameHint>
- <references xmlns="http://schemas.microsoft.com/BizTalk/2003">
<reference targetNamespace="http://Microsoft.LobServices.OracleDB/2007/03" />
</references>
</xs:appinfo>
</xs:annotation>
- <xs:element name="BTS_RAD_POLLMANAGESTATEDOCAMD">
- <xs:annotation>
- <xs:documentation>
<doc:action xmlns:doc="http://schemas.microsoft.com/servicemodel/adapters/metadata/documentation">http://Microsoft.LobServices.OracleDB/2007/03/RADAR/PollingProcedure/BTS_RAD_POLLMANAGESTATEDOCAMD</doc:action>
</xs:documentation>
</xs:annotation>
- <xs:complexType>
- <xs:sequence>
<xs:element minOccurs="1" maxOccurs="1" name="P_RC" nillable="true" type="ns3:ArrayOfGenRecordRow" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
now at adminstration level i have made below config setting at receive location, please help where i am doing wrong.
Trasport Type : WCF-OracleDB
EnableBiztalkcompatibilityMode : True
PollDataAvilableStatment : SELECT count(*) FROM RAD_BTS_MANAGE_DOCAMS WHERE MESSAGE_STATE='CREATED'
Polling Action : http://Microsoft.LobServices.OracleDB/2007/03/RADAR/PollingProcedure/BTS_RAD_POLLMANAGESTATEDOCAMD
polling Statement :
use ambient Transaction : False
I doubt there is someprob with polling Statement .
Could you some one suggest, in my SP its not in out Courser, its just out. How should i write or let me know where it might be going wrong.
Error I am getting:
The adapter "WCF-OracleDB" raised an error message.
Details "Microsoft.ServiceModel.Channels.Common.XmlReaderParsingException: Unexpected start node "BTS_RAD_POLLMANAGESTATEDOCAMD" with namespace "http://Microsoft.LobServices.OracleDB/2007/03/RADAR/PollingProcedure/BTS_RAD_POLLMANAGESTATEDOCAMD" found.
at Microsoft.ServiceModel.Channels.Common.Design.AdapterAsyncResult.End()
at Microsoft.ServiceModel.Channels.Common.Channels.AdapterInputChannel.EndTryReceive(IAsyncResult result, Message& message)
at System.ServiceModel.Dispatcher.InputChannelBinder.EndTryReceive(IAsyncResult result, RequestContext& requestContext)
at System.ServiceModel.Dispatcher.ErrorHandlingReceiver.EndTryReceive(IAsyncResult result, RequestContext& requestContext)".
You should import the binding file generated by the Wizard.
The Assembly with the Schema has to be Deployed.
Finally i could sort out the ans,
I have done some of the mistakes which i corrected,
Trasport Type : WCF-OracleDB
EnableBiztalkcompatibilityMode : True
PollDataAvilableStatment : SELECT count(*) FROM RAD_BTS_MANAGE_DOCAMS WHERE MESSAGE_STATE='CREATED' Polling Action : http://Microsoft.LobServices.OracleDB/2007/03/RADAR/PollingProcedure/BTS_RAD_POLLMANAGESTATEDOCAMD polling Statement :
<ns0:BTS_RAD_POLLMANAGESTATEDOCAMD xmlns:ns0="http://Microsoft.LobServices.OracleDB/2007/03/RADAR/Procedure">
<ns0:P_RC_IN>OPEN ? FOR SELECT * FROM RAD_BTS_MANAGE_DOCAMS WHERE MESSAGE_STATE='CREATED';</ns0:P_RC_IN>
</ns0:BTS_RAD_POLLMANAGESTATEDOCAMD>
use ambient Transaction : False
my mistake was i was calling url of polling action in Polling statement at xmlns. Where here the URL is suppose to be from of different Schema.
the other mistake is in my statement i didnt include ;.
here is the part of xsd-scheme:
<xsd:complexType name="TGroups">
<xsd:choice>
<xsd:element name="GROUP1"/>
<xsd:element name="GROUP2"/>
</xsd:choice>
</xsd:complexType>
Is there any way to get all TGroups values ("GROUP1", "GROUP2") from xsd as collection (Set, List, String[], ...) using JAXB or something else?
Thank you for reply.