Is there an easier way to do this
<Elements>
{
for $i in ("a", "b", "c")
return <Element name="{$i}"/>
}
</Elements>
in xquery?
You can use fn:map() is your XQuery processor has XQuery 3.0 support:
fn:map(function($e){ <Element name="{$e}" /> }, $sequence)
I don't really understand your question. What do you mean by easier?
How about:
<Elements>
<Element name="a" />
<Element name="b" />
<Element name="c" />
</Elements>
I also wonder what do you mean by "easier".
Have all items in a variable $seq and use:
for $i in 1 to count($seq)
return <Element name="{$seq[$i]}"/>
Here is a whole XQuery program:
let $seq := 1 to 15
return
for $i in 1 to count($seq)
return <Element name="a{$seq[$i]}"/>
and it produces the correct, wanted result:
<Element name="a1"/>
<Element name="a2"/>
<Element name="a3"/>
<Element name="a4"/>
<Element name="a5"/>
<Element name="a6"/>
<Element name="a7"/>
<Element name="a8"/>
<Element name="a9"/>
<Element name="a10"/>
<Element name="a11"/>
<Element name="a12"/>
<Element name="a13"/>
<Element name="a14"/>
<Element name="a15"/>
Related
I am not sure if ScriptAssert can be applied on Field. I am trying the below ScriptAssert but all the time it returns the message "Value is Mandatory" even the _this.OBJSTATE != 'CANCELLED'. Can someone please help??
<?xml version="1.0" encoding="UTF-8"?>
<constraint-mappings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/mapping validation-mapping-1.0.xsd"
xmlns="http://jboss.org/xml/ns/javax/validation/mapping">
<default-package>x.x</default-package>
<bean class="x.class" ignore-annotations="true">
<field name="OBJSTATE">
<constraint annotation="javax.validation.constraints.Pattern">
<message>Value should be CANCELLED/RELEASED</message>
<element name="regexp">^(CANCELLED)$|^(RELEASED)$</element>
</constraint>
<constraint annotation="javax.validation.constraints.NotNull">
<message>Field is Mandatory</message>
</constraint>
<constraint annotation="org.hibernate.validator.constraints.NotBlank">
<message>Value is Mandatory</message>
</constraint>
</field>
<field name="T1PONumber">
<constraint annotation="org.hibernate.validator.constraints.ScriptAssert" >
<message>Value is Mandatory</message>
<element name="lang">javascript</element>
<element name="script" >
<value>_this.OBJSTATE == 'CANCELLED'</value>
</element>
</constraint>
</field>
</bean>
</constraint-mappings>
ScriptAssert should be applied to class level
<bean class="x.class" ignore-annotations="true">
<class ignore-annotations="false" >
<constraint annotation="org.hibernate.validator.constraints.ScriptAssert">
<message>T1PONumber value is Mandatory</message>
<element name="lang">javascript</element>
<element name="script" >
<value>_this.OBJSTATE != 'CANCELLED'</value>
</element>
</constraint>
</class>
<field name="OBJSTATE">
<constraint annotation="javax.validation.constraints.Pattern">
<message>Value should be CANCELLED/RELEASED</message>
<element name="regexp">^(CANCELLED)$|^(RELEASED)$</element>
</constraint>
<constraint annotation="javax.validation.constraints.NotNull">
<message>Field is Mandatory</message>
</constraint>
<constraint annotation="org.hibernate.validator.constraints.NotBlank">
<message>Value is Mandatory</message>
</constraint>
</field>
<field name="T1PONumber">
</field>
</bean>
In visual studio (web.config transformations) I have a transformation I want to perform which adds two attributes on the root element.
One attrbute works (but not multiple ones).
And I can set multiple attributes on a child element.
I have tried SetAttributes with and without specifying the names of the attributes, no luck.
Ideas??
example
<element xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform" xdt:Transform="SetAttributes" attrOne="One" attrTwo="Two">
<children>
<child name="One" xdt:Transform="SetAttributes" attrOne="One" attrTwo="Two" />
</children>
</element>
desired effect
<element attrOne="One" attrTwo="Two">
<children>
<child name="One" attrOne="One" attrTwo="Two" />
</children>
</element>
The "element" section is really a custom section of the web.config file...like so:
<configuration>
... <element configSource="App_Data\element.config" />
this transformation is meant to be used on the element.config file (using slow cheetah)
Update
This apparently doesn't work either:
<element xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform" xdt:Transform="Replace" attrOne="One" attrTwo="Two">
<children>
<child name="One" attrOne="One" attrTwo="Two" />
</children>
</element>
But this does:
<element xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform" xdt:Transform="Replace" attrOne="One">
<children>
<child name="One" attrOne="One" attrTwo="Two" />
</children>
</element>
As soon as there are more than 1 attribute on the root element it fails
Have you tried a document transform like this that sets multiple attributes at the same time by passing a list of attributes to set to SetAttribute()?
See here form more info.
Specifically: Transform="SetAttributes(comma-delimited list of one or more attribute names)"
<element xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform" xdt:Transform="SetAttributes(attrOne,attrTwo)" attrOne="One" attrTwo="Two">
<children>
<child name="One" xdt:Transform="SetAttributes(attrOne,attrTwo)" attrOne="One" attrTwo="Two" />
</children>
</element>
The document element of a web.config file is <configuration>. In your example, <element> is probably a child of <configuration>. Try:
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<element xdt:Transform="SetAttributes" attrOne="One" attrTwo="Two">
<children>
<child xdt:Transform="SetAttributes" name="One"
attrOne="One" attrTwo="Two" />
</children>
</element>
</configuration>
Is there a way to assign a list of strings from input variable to invoke input variable?The problem is that there are multiple inputs in my web service so i am not able to copy the wrapping element in input variable to wrapping variable in invoke variable.Will copy the snippet of the code here :
<assign name="Assign1">
<copy>
<from variable="inputVariable" part="payload"
query="/ns2:process/ns2:dsaName"/>
<to variable="Invoke1_processList_InputVariable"
part="parameters" query="/ns1:processList/dsaName"/>
</copy>
<copy>
<from variable="inputVariable" part="payload"
query="/ns2:process/ns2:linesOfData"/>
<to variable="Invoke1_processList_InputVariable"
part="parameters" query="/ns1:processList/linesOfData"/>
</copy>
<copy>
<from variable="inputVariable" part="payload"
query="/ns2:process/ns2:description"/>
<to variable="Invoke1_processList_InputVariable"
part="parameters" query="/ns1:processList/description"/>
</copy>
<copy>
<from variable="inputVariable" part="payload"
query="/ns2:process/ns2:application"/>
<to variable="Invoke1_processList_InputVariable"
part="parameters" query="/ns1:processList/application"/>
</copy>
</assign>
The problem is that only one is of list type all others are of string type.The XML for this is:
<element name="process">
<complexType>
<sequence>
<element name="dsaName" type="string" minOccurs="0"/>
<element name="linesOfData" type="string" minOccurs="0" maxOccurs="unbounded"/>
<element name="description" type="string" minOccurs="0"/>
</sequence>
</complexType>
</element>
<element name="processResponse">
<complexType>
<sequence>
<element name="result" type="string" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</complexType>
</element>
</schema>
Looking at your schema, you can use doXSLTransform operation where <xsl:for-each> is used to read the list type (here it's linesOfData) and add each of those elements to Invoke1_processList_InputVariable.
I need to traverse an array (input to BPEL) in java embed activity and need to generate a response (output variable) of BPEL process.
I am using Jdeveloper and SOA 11g
following is my xsd
<?xml version="1.0" encoding="UTF-8"?>
<schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://xmlns.oracle.com/BPELInpuandOutPutArray_jws/Project1/BPEL_input_output_array" xmlns="http://www.w3.org/2001/XMLSchema">
<element name="process">
<complexType>
<sequence>
<element name="simpleinput" type="string"/>
<element name="arrayofObjects" maxOccurs="unbounded" nillable="true">
<complexType>
<sequence>
<element name="input1" type="string"/>
<element name="input2" type="string"/>
</sequence>
</complexType>
</element>
</sequence>
</complexType>
</element>
<element name="processResponse">
<complexType>
<sequence>
<element name="arrayofObjectsoutput" maxOccurs="unbounded" nillable="true">
<complexType>
<sequence>
<element name="output1" type="string"/>
<element name="output2" type="string"/>
</sequence>
</complexType>
</element>
</sequence>
</complexType>
</element>
</schema>
so far I am able to manage for traversing in input array
oracle.xml.parser.v2.XMLElement e1=
(oracle.xml.parser.v2.XMLElement)getVariableData("inputVariable","payload","/client:process/client:arrayofObjects[1]/client:input1");
System.out.println(e1.getFirstChild().getNodeValue());
But my business requirement is to based on some logic set the values in output array.
for this I used following sample code.
for(int i=1; i < 4 ;i++)
{
setVariableData("outputVariable","payload","/client:processResponse/client:arrayofObjectsoutput['i']/client:output1",i);
setVariableData("outputVariable","payload","/client:processResponse/client:arrayofObjectsoutput['i']/client:output2",i);
}
My feeling is array would be created of length 3 and value will be settes(1,1) (2,2) (3,3) but at the output value is only (3,3) .
please tell me how can i achieve the same.
sample code will be appreciated.
The way I did it for a similar situation was to use a transformation to create the first element and then use the bpelx:insertAfter to insert additional array elements and then set them.
<assign name="Assign_2">
<bpelx:insertAfter>
<bpelx:from variable="outputVariable" part="payload"
query="/client:ArrayManipulationProcessResponse/client:arrayofObjectsoutput"/>
<bpelx:to variable="outputVariable" part="payload"
query="/client:ArrayManipulationProcessResponse/client:arrayofObjectsoutput"/>
</bpelx:insertAfter>
<copy>
<from expression="'MyOutput1-Index2'"/>
<to variable="outputVariable" part="payload"
query="/client:ArrayManipulationProcessResponse/client:arrayofObjectsoutput[2]/client:output1"/>
</copy>
<copy>
<from expression="'MyOutput2-Index2'"/>
<to variable="outputVariable" part="payload"
query="/client:ArrayManipulationProcessResponse/client:arrayofObjectsoutput[2]/client:output2"/>
</copy>
</assign>
If proprietary extensions do not work, you can try the standard BPEL approach and use an XSLT script to iteratively construct a result document.
An example is given in the BPEL 2.0 specification, pp 65, look for Iterative document construction.
Basically, the list and the element to add is passed (via the doXSLTransform XPath function) to an XSLT script, which copies the element to add to the list and returns the new document. This is then assigned to a variable.
I feel there is no need to write custom Java code for such a simple task. The following code (BPEL2.0) does the job of copying the values.<assign name="Copy values">
<extensionAssignOperation>
<bpelx:copyList>
<bpelx:from>$inputVariable.payload/ns1:arrayofObjects</bpelx:from>
<bpelx:to>$outputVariable.payload/ns1:arrayofObjectsoutput</bpelx:to>
</bpelx:copyList>
</extensionAssignOperation>
</assign>
I want to add new configuration section definition in <configSections> in my web.config file using the IIS7 Management Console Configuration Editor and generate a script and execute this script in the installation to update the client's production servers.
I was able to add the section definition using the following code:
ServerManager serverManager = new ServerManager();
Configuration config =
serverManager.GetWebConfiguration("Default Web site/upngisintegration");
SectionGroup rootSectionGroup = config.RootSectionGroup;
SectionDefinition logSectiondef =
rootSectionGroup.Sections.Add("loggingConfiguration");
logSectiondef.Type =
#"Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings,
Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=null";
serverManager.CommitChanges();
However, I don't know how to add the configuration detail (see below).
How do I do this?
Section Definition:
<section name="loggingConfiguration"
type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings,
Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=null" />
Section Details:
<loggingConfiguration
name="Logging Application Block"
tracingEnabled="true"
defaultCategory="General">
<listeners>
<add fileName="C:\temp\xxxxx.log" ..snipped for brevity.. />
<add timestampFormat="MM-dd-yyyy HH-mm-ss" ..snipped for brevity... />
</listeners>
<formatters>
<add template="...." ..snipped for brevity.../>
</formatters>
<categorySources>
<add switchValue="All" name="General">
<listeners>
<add name="RollingFile TraceListener" />
</listeners>
</add>X
<add switchValue="All" name="Inbound Outbound Trans">
<listeners>
<add name="RollingFile TraceListener" />
</listeners>
</add>
</categorySources>
<specialSources>
<allEvents switchValue="All" name="All Events" />
<notProcessed switchValue="All" name="Unprocessed Category" />
<errors switchValue="All" name="Logging Errors & Warnings">
<listeners>
<add name="RollingFile TraceListener" />
</listeners>
</errors>
</specialSources>
</loggingConfiguration>
After couple of days of research i had to do the following steps to generate the required scripts.
Create a custom_schema.xml with the
schema definition for Logging
Application Block(see below) .. it
is a very tedious process
Copy that file C:\Windows\System32\inetsrv\config\schema
Add a Section definition in the
web.config (application's
web.config) manually
Open the IIS7 Console->Click on the
Configuration Editor (Security
group)
Select the above added section (it
should appear in the list -
loggingConfiguration)
It should show you the complete
definition
Edit the required value (funny thing
is we have to edit all the
values,even though you have default
values, otherwise you will get only
the changed values in the script)
You can click on the Generate Script
link
See below for sample custom_schema.xml
--- Logging Application block's Schema details (CUSTOM_schema.xml)
<configSchema>
<sectionSchema name="loggingConfiguration">
<attribute name="name" type="string" />
<attribute name="tracingEnabled" type="bool" defaultValue="true"/>
<attribute name="defaultCategory" type="string" defaultValue="General"/>
<attribute name="type" type="string" defaultValue="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"/>
<element name="listeners">
<collection addElement="add" removeElement="remove" clearElement="clear">
<attribute name="fileName" required="true" type="string" defaultValue="c:\temp\log.log" />
<attribute name="header" required="true" type="string" defaultValue="-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-" />
<attribute name="footer" required="true" type="string" defaultValue="-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-" />
<attribute name="formatter" required="true" type="string" defaultValue="Text Formatter" />
<attribute name="listenerDataType" required="true" type="string" defaultValue="LogicaCMG.EnterpriseLibraryExtensions.Logging.Configuration.RollingFileTraceListenerData, LogicaCMG.EnterpriseLibraryExtensions.Logging, Version=0.5.2.0, Culture=neutral, PublicKeyToken=null" />
<attribute name="traceOutputOptions" required="true" type="string" defaultValue="None" />
<attribute name="type" type="string" required="true" defaultValue="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" />
<attribute name="name" type="string" required="true" defaultValue="RollingFile TraceListener" />
<attribute name="ageThreshold" type="string" required="true" defaultValue="1" />
<attribute name="ageUnit" type="string" required="true" defaultValue="Days" />
<attribute name="sizeThreshold" type="string" required="true" defaultValue="2" />
<attribute name="sizeUnit" type="string" required="true" defaultValue="Megabytes" />
<attribute name="maximumNumberOfLogs" type="string" required="true" defaultValue="20" />
<attribute name="timestampFormat" type="string" required="true" defaultValue="MM-dd-yyyy HH-mm-ss" />
</collection>
</element>
<element name="formatters">
<collection addElement="add" removeElement="remove" clearElement="clear">
<attribute name="template" required="true" type="string" defaultValue="Timestamp:{timestamp(local:F)}
Message: {message}
Category: {category}
Priority: {priority}
Severity: {severity}" />
<attribute name="type" type="string" required="true" defaultValue="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" />
<attribute name="name" required="true" type="string" defaultValue="Text Formatter" />
</collection>
</element>
<element name="categorySources">
<collection addElement="add" removeElement="remove" clearElement="clear">
<attribute name="switchValue" required="true" type="string" defaultValue="All" />
<attribute name="name" required="true" type="string" defaultValue="General"/>
<element name="listeners">
<collection addElement="add" removeElement="remove" clearElement="clear">
<attribute name="name" required="true" type="string" defaultValue="RollingFile TraceListener"/>
</collection>
</element>
</collection>
</element>
<element name="specialSources">
<element name="allEvents">
<attribute name="switchValue" type="string" defaultValue="All"/>
<attribute name="name" type="string" defaultValue="All Events"/>
</element>
<element name="notProcessed">
<attribute name="switchValue" type="string" defaultValue="All"/>
<attribute name="name" type="string" defaultValue="Unprocessed Category"/>
</element>
<element name="errors">
<attribute name="switchValue" type="string" defaultValue="All"/>
<attribute name="name" type="string" defaultValue="Logging Errors & Warnings"/>
<element name="listeners">
<collection addElement="add" removeElement="remove" clearElement="clear">
<attribute name="name" type="string" defaultValue="RollingFile TraceListener"/>
</collection>
</element>
</element>
</element>
</sectionSchema>
</configSchema>