Given a DataMapper node that would map between the following two structures:
Strcuture A:
<item>
<id>123</id>
<price>1</price>
<quantity>1</quantity>
</item>
<item>
<id>124</id>
<price>2</price>
<quantity>1</quantity>
</item>
<item>
<id>125</id>
<price>3</price>
<quantity>1</quantity>
</item>
Structure B:
<total>
<totalPrice>6</totalPrice>
</total>
The Mule ESB DataMapper will generate a CTL2 (Clover) Transformation.
Can the Mule ESB DataMapper also generate XSLT
Do you mean to perform a XML transformation? Because if this is the case then yes.
If what you mean is to generate XSLT, technically I can, but makes no sense as XSLT is not meant to contain information but rather to transform it.
I guess XSLT (Extensible Stylesheet Language Transformations) is a language for transforming XML documents into other XML documents and I am afraid Data mapper cannot generate a XSLT ...
you can always use Mule XSLT transformer separately to transform data into your expected format of XML:- http://www.mulesoft.org/documentation/display/current/XSLT+Transformer
You can use XSLT component and provide an xsl file. This xsl file would be convert between 2 different sml formats.
Below is the example of mule flow for the same.
<file:connector name="File" autoDelete="true" streaming="true" validateConnections="true" doc:name="File"/>
<flow name="xsltexampleFlow">
<file:inbound-endpoint path="D:\Mule_Work\Input" connector-ref="File" responseTimeout="10000" doc:name="File"/>
<logger message="------------------File Read------------" level="INFO" doc:name="Logger"/>
<mulexml:xslt-transformer xsl-file="D:\Mule_Work\Output\transform.xsl" maxIdleTransformers="2" maxActiveTransformers="5" doc:name="XSLT"/>
<logger level="INFO" doc:name="Logger" message="--------------XSL Transformation---------------------"/>
<file:outbound-endpoint path="D:\Mule_Work\Output" outputPattern="Output_transform.xml" connector-ref="File" responseTimeout="10000" doc:name="File"/>
</flow>
Related
I am doing a Response.Redirect to below given xml document with a query string parameter.
Response.Redirect(#"../temp/output.xml?location=newlocation");
What I want is that the value of location attribute for all the product nodes should be replaced with the value I pass in query string parameter. The problem is when I do a response.redirect to xml the c# server code which modifies the xml document does not executes for the obvious reason that xml file does not runs any server code.
Can anyone please suggest a solution for this.
Xml File
<?xml version="1.0" encoding="utf-8"?>
<products xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="products:noNamespaceSchemaLocation">
<store id="BND088412">
<display-name>test</display-name>
</store>
<product location="test">
<length units="minutes">100</length>
<title>Microsoft Excel</title>
</product>
<product location="test">
<length units="minutes">300</length>
<title>Microsoft VBA</title>
</product>
</products>
Thanks & Regards
I have a webapi controller that returns an Items object like:
<Items>
<Item>
<Color>PINK</Color>
<CommercialProductBundle>NOTAPPLICABLE</CommercialProductBundle>
<Descriptions/>
</Item>
<Item>
<Color>Black</Color>
<CommercialProductBundle>NOTAPPLICABLE</CommercialProductBundle>
<Descriptions/>
</Item>
</Items>
In order to use ODATA query functionality I changed the return type from
public Items GetAllItems()
where Items is 'List' to
IQueryable GetAllItems() .
But then my response shows in stead of :
<ArrayOfItem xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Item>
<Color>PINK</Color>
<CommercialProductBundle>NOTAPPLICABLE</CommercialProductBundle>
<Descriptions/>
</Item>
<Item>
<Color>Black</Color>
<CommercialProductBundle>NOTAPPLICABLE</CommercialProductBundle>
<Descriptions/>
</Item>
</ArrayOfItem>
Is there a way to get rid of the 'ArrayOf', showing again the initial xml?
Thanks for any help.
Have you let your controller derive from ODataController? Have you installed the ASP.NET Web API OData V1-3 assemblies? Have you modified your WebApiConfig.cs to map the OData route?
As OData queryability depends on its unique routing convention and the Web API configuration, you might want to follow this tutorial to http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api/odata-v3/creating-an-odata-endpoint and implement accordingly for getting this querability.
I'm working with dexterity xml models and am looking for a way to extract i18n strings from my models. It doesn't look like i18ndude or infrae.i18nextract do this. As a result all the translations strings in my xml models don't show in the generated .pot files.
Some of the models have more than 30 fields, so manual extraction is becoming tedious.
i18ndude do extract i18n messages from model files without any issues; check you're including your domain and marking the strings to be extracted.
see our i18n script and check compare, as an example, collective.cover's model with yours:
<?xml version="1.0" ?>
<model xmlns="http://namespaces.plone.org/supermodel/schema"
xmlns:form="http://namespaces.plone.org/supermodel/form"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
i18n:domain="collective.cover">
<schema>
<field name="template_layout" type="zope.schema.Choice" form:widget="collective.cover.widgets.selectpreview.SelectFieldWidget"
form:omitted="z3c.form.interfaces.IEditForm:true">
<description i18n:translate=""
>Choose one of the predefined layouts</description>
<title i18n:translate="">Layout</title>
<vocabulary>collective.cover.AvailableLayouts</vocabulary>
<default>Empty layout</default>
</field>
<field name="cover_layout" type="zope.schema.Text"
form:omitted="z3c.form.interfaces.IForm:true
z3c.form.interfaces.IAddForm:true
z3c.form.interfaces.IEditForm:true">
<description i18n:translate=""
>The layout to be used to render groups and tiles</description>
<title i18n:translate="">Cover Layout</title>
</field>
</schema>
</model>
Using Biztalk 2010 I have a incoming message with this structure:
<xml><blocks>
<block id="level">
<message id="code">100</message>
<message id="description">Some description</message>
</block>
<block id="level">
<message id="code">101</message>
<message id="description">More description</message>
</block>
</blocks>
<blocks>
<block id="change">
<message id="table">1</message>
<message id="oldvalue">100</message>
<message id="newvalue">101</message>
</block>
</blocks>
</xml>
I need to map the above to this structure:
<terms>
<termItem>
<code>100</code>
<description>Some description</description>
<deleted>false</deleted>
</termItem>
<termItem>
.....and so on with values from the above xml file, except that the item from the "change" block should be added as a new record to output, so the total output will be 3 items (<block>).
The map view is like this:
I need some help in choosing the right combination of either functoids to use, or maybe another approach to solve this challenge.
I'm able to either choose all blocks with the "level" value and filter out the "change" block, but unable to make a combination of the two.
Any hints, suggestions are very welcome.
Thanks
There seems to be more than meets the eye
The incoming xml seems to be nested (as per the schema in the visual mapper), so the example input xml structure might not quite be right?
Also, it might be that the schema on the RHS is debatched, i.e. one PaymentTerms message per company id, so unless you only need to map the first Company, you will need to create a wrapper schema for all mapped companies, with an arbitrary root node, and then debatch them before sending.
That said, it is relatively straightforward to get the general structure of the output by using a custom xslt instead of the visual mapper. I've assumed the RHS schema on your diagram for the real output schema (not your terms example).
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
exclude-result-prefixes="xsl xsi">
<xsl:output method="xml" indent="yes" />
<xsl:strip-space elements="*" />
<!--Outer template-->
<xsl:template match="/">
<PaymentTerms CompanyCode="Unsure">
<xsl:apply-templates />
</PaymentTerms>
</xsl:template>
<!--Root blocks only-->
<xsl:template match="block[#id='level']">
<PaymentTerm>
<Code>
<xsl:value-of select="message[#id='code']/text()"/>
</Code>
<Description>
<xsl:value-of select="message[#id='description']/text()"/>
</Description>
<Deleted>
<!--No idea how you want this populated-->
<xsl:value-of select="'false'"/>
</Deleted>
</PaymentTerm>
<xsl:apply-templates select="blocks/block"></xsl:apply-templates>
</xsl:template>
<!--Nested blocks only-->
<xsl:template match="block[#id='change']">
<PaymentTerm>
<Code>
NestedCode
</Code>
<Description>
NestedDescription
</Description>
<Deleted>
NestedDeleted
</Deleted>
</PaymentTerm>
</xsl:template>
</xsl:stylesheet>
You didn't provide much info on how the nested blocks are to be mapped, so I've provided placeholders in the meantime.
HTH!
I am trying to access getListItems method of the Lists service of Sharepoint from Flex using WebService.
It is working fine when I omit the query and the viewFields nodes in the request xml.
But if I add any query or FieldRef in Viewfields it is throwing error from the service.
Below is the code.
<mx:WebService id="ws2" wsdl="{url}/_vti_bin/Lists.asmx?WSDL" result="ws2result(event)" fault="ws2fault(event)" showBusyCursor="true">
<mx:operation name="GetListItems" resultFormat="e4x">
<mx:request xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<listName>{listId}</listName>
<viewName>{viewId}</viewName>
<ViewFields><FieldRef Name='Locations'/></ViewFields>
</mx:request>
</mx:operation>
</mx:WebService>
It is working fine without the ViewFields.
Can we use the ViewFields and query from flex?
Also is there any way to get the sum of items satisfying a specific condetions using this service?
Applied the new format. But still its throwing error.
The SOAP message captured from fiddler.
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<tns:GetListItems xmlns:tns="http://schemas.microsoft.com/sharepoint/soap/"> <tns:listName>{0A1C8CDA-E738-46B7-923D-1D2C599D960F}</tns:listName>
<tns:viewFields>
<tns:Name>ID</tns:Name>
</tns:viewFields>
</tns:GetListItems>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
But the message in the operation tag is passed as below.
<mx:operation name="GetListItems" >
<mx:request xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<listName>\{0A3C3DCA-E744-46C7-916D-1D2C539A960F\}</listName>
<viewFields>
<ViewFields>
<FieldRef Name="ID" />
</ViewFields>
</viewFields>
</mx:request>
</mx:operation>
I can't tell for sure without seeing a sample of the actual SOAP message going over the wire, but I believe you're missing some containing elements in the request.
For your query, it needs to be structured as:
<query>
<Query>
<{CAML QUERY HERE}>
</Query>
</query>
Note the case of the containing <query>. Same song, different verse for ViewFields:
<viewFields>
<ViewFields>
<FieldRef Name="foo" />
</ViewFields>
</viewFields>
QueryOptions must also be contained in a <queryOptions> element. Crazy SharePoint!