I have this data (all the elements are optional):
<data>
<optionalElement1>...</optionalElement1>
<optionalElement2>...</optionalElement2>
<optionalElement3>...</optionalElement3>
</data>
I need to map this to another schema (all the elements are required):
<request>
<Element1>...</Element1>
<Element2>...</Element2>
<Element3>...</Element3>
</request>
Since the elements in the original request are optional, the mapping will
only generate the corresponding elements for the originally included
elements. But the validation of the request will fail.
Example:
<data>
<optionalElement3>
<value1>1</value1>
<value2>2</value2>
</optionalElement3>
</data>
will be mapped to
<request>
<Element3>
<subelement1>1</subelement1>
<subelement2>2</subelement2>
</Element3>
</request>
And the validation will fail because i'm missing Element1 and Element2. The
response should be (I think):
<request>
<Element1 xsi:nil="true" />
<Element2 xsi:nil="true" />
<Element3>
<subelement1>1</subelement1>
<subelement2>2<subelement2>
</Element3>
</request>
How can I do this in the mapping? How can I ensure that the element is
created in the output message?
And, by the way, if a subelement is not present (let's say
"data/optionalElement1/value1" how can I make sure that the destination
subelement "request/Element1/subelement1" is created?
Make it very simple. Use the xlst file for mapping.
Using simple if condition you can check for value exist for opetion element or not, if value exist then map that else map the null (Empty) value. So the complex element will get generated even if there is no value for optional element.
Hope it will solve your problem.
You can do all this in the mapper. I haven't been into Biztalk for a while and I don't have it near me, but I know there are functiods in the mapper that lets you check for the existence of the fields you need. Depending on the existence of these field, you can specify what the appropriate action for the mapper is.
You force the creation of fields by giving them default values in the target schema. This can also be done using the mapper, via the properties window.
Jose,
You'll want to look at the table looping functoid. Here's a post about it.
http://geekswithblogs.net/Chilberto/archive/2008/04/16/121274.aspx
Using this functoid with the table extraction should give you your solution. Also here's a good series on understadning the mapper.
http://www.bizbert.com/bizbert/2008/02/07/Understanding+The+BizTalk+Mapper+Part+1+Introduction.aspx
-Bryan
Related
I use XSLT 1.0 to transform source XML file to HTML document. In source file there are section elements.
<section name="Name of this section">
...
</section>
And it is transformed to HTML as following (h2 may change to h3, h4, etc. according to the level of nesting).
<h2 id="...">Name of this section</h2>
id attribute is used to reference this section from other HTML document.
Link to the section
Currently geterate-id function is used to generate the value of id attribute. But it may change when structure of source XML file is changed. And it results in breakage of link from other HTML document. So I would like to make value of id attribute constant even if structure of source file is changed.
At first I considered using the value of name attribute. But sometimes it includes characters that is improper as a part of URL (space, question mark, non-ASCII UTF-8 characters, etc.). So it can't be used.
Next I considered adding id attribute to section element of source XML file and using it as is in HTML file. It surely provide proper value but adding it to all section element in source file is bothersome. So I would like to think of it as last resort.
Then is there any way to generete the value of id attribute that is constant regardless of change of source file and also proper as a part of URL?
Maintainer of documents referencing mine told me encode-for-uri() of XSLT 2.0 and str:encode-uri() of EXSLT. I use xsltproc of libxslt as processor and it supports EXSLT. So I decided to use str:encode-uri(#name) as value of id attribute. There are two drawbacks about it. At first it doesn't guarantee uniqueness. If there are multiple section elements with the same name attribute value in source XML file, then id value will be duplicated. The second point is that when the value of the name attribute changes, the id value also changes. However, in my case they don't really matter. The value of name attribute is unique within source file and seldom changed. So I can make id unique and almost constant enough for my case.
HTTP GET, retrive values from an xml
and than I need to call a PUT many times as the number of element with some values I got from the first GET.
I have an xml for example
<root>
<element>
<valId>1111</valId>
<valName>Name</valName>
</element>
<element>
<valId>1111</valId>
<valName>Name</valName>
</element>
....
</root>
So I have:
HTTP GET: retrive an xml
xpath extractor 1 for valsId
xpath extractor 2 for valsName
Now I have two array with multiple values in valId and valName, I can access to them with valsId_1, valsId_2, etc
Then I have a foreach controller in input I have valsId and output the current value myId.
as child of foreach controller I have my http PUT where I use myId but I don't know how to get the current value of valsName.
In my opinion for this kind of problem there two way:
1 extract the values in array, as I did
2 extract a part of xml and than process it everytime in a for
I hope you understand what I meant with my problem.
Any suggestions are welcome
For handling second variable "valsName" just place below code
${__BeanShell(vars.get("valsName_"+${__counter(TRUE,page)}))}
at the position of Name
<valName>Name</valName>
it'll resolve your problem.
Im trying to create some custom blocks for a CMS interface based on the symfony-cmf. In order for these blocks to be edited inline with createphp/hallo i need to create RDFa mappings for them.
The basic example for an included block is something like the following:
<type
xmlns:sioc="http://rdfs.org/sioc/ns#"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:skos="http://www.w3.org/2004/02/skos/core#"
typeof="sioc:Post"
>
<attribute key="class" value="articleContainer span3"/>
<children>
<property property="dcterms:title" identifier="title" tag-name="h2"/>
<property property="sioc:content" identifier="content" />
</children>
</type>
Which would yield something like this:
<h2>The title input</h2>
<p>the content, however i beleive the actual <p> tag is applied by the editor</p>
Thats all well and good... What Im having a hard time figuring out how to define this mapping for a resource that will be something like this:
<h1>Text string with <strong>emphasized phrase</strong> in the middle</h1>
I could probably just use the sioc:content type and then rely on the user to "bold" the emphasized phrase in the editor but i would rather have it be edited explicitly.
Is there a way to do this? Also if anyone could point me towards solid RDFa tutorials that would be great. My google-fu is usually strong but all i can seem to find are the actual spec, and a bunch of posts about seemingly unrelated usages.
The idea of the RDFa mapping is to specify which properties of the document you want to render with which tags. Actual content typically is WYSIWYG. I guess RDFa being quite complex it would support inline-nested information like what you are asking for. But the midgard/createphp component which reads this XML configuration to generate the right data does not support nested content. I am not sure if create.js would support it, but i think not.
Note that you can map children and output whole content hierarchies. But that would not handle your emphasised fragment.
I have hashmap that was created on a page using the struts2 <s:set> tag. It looks something like this
<s:set var="mymap" value="#request.mymap"/>
At some point in the page, i need to get a value from the hashmap based upon a key, and i want to do it using OGNL.
The key is generated based upon some logic, which i store using another <s:set> tag. Something like this
<s:set var="mykey" value="1">
I need to get a value from the hashmap using this key. And I need to display it.
How do I simply call the get function on the hashmap?
I tried this
<s:property value="#mymap[#mykey]"/>
and this
<s:property value="#mymap[%{#mykey}]"/>
and this
<s:property value="%{#mymap[%{#mykey}}]"/>
The third one obviously does not work because of the nesting problem.
But the same nesting logic is applicable to the second case as well, due to the manner the value attribute is handled. However none seem to work for me.
The issue here is that my key is unknown. It is a dynamically generated string based upon some pattern. I need to access the object stored in the hashmap using this dynamic key. And due to the inability of nesting ognl, I am in a fix.
I suppose the issue is very simple. I almost feel that I get it, but somehow the solution eludes me.
I suppose I was using a different version of struts wherein using the %{} was required for the expression to be evaluated. I changed the jar files now.
This is what did the job for me:
<s:property value="#mymap.[#mykey2]"/>
My problem was coming because I was trying to use it in a href for a s:a tag. And without the %{} operator, the expression was not being evaluated.
So, i guess, i was right in the beginning itself. Rest of the time, it was just me being silly. :>
Update:
I wrote a blog post on the issue, in case anyone is interested.
http://mycodefixes.blogspot.com/2010/11/struts-2-creating-and-accessing-maps.html
The following question was posted in other forum, but there was no response, I am facing the same problem and I think it will get some answers here :
Question :
I am making use of the SharePoint 2007 GetListItems web service to programatically retrieve all documents within a document library. However, my program is throwing an Exception due to an invalid character contained within the XML response. The bad data is within the Word document itself. There are control characters within the Comments section of the document properties. The bad characters are then ending up as in the ows_MetaInfo field in the XML output which is invalid.
I have no need for the ows_MetaInfo field and so I have been trying to use the viewFields parameter to specify which fields to return along with setting the query option IncludeMandatoryColumns to false but the ows_MetaInfo field is always returned.
Does anyone know if it is possible to remove the ows_MetaInfo field from the output or somehow handle these invalid characters that are appearing in the XML output
In my case (SharePoint 2010) this solved the problem:
<soap:viewFields>
<ViewFields Properties="True">
<FieldRef Name="MetaInfo" Property="ModifiedBy" />
<FieldRef Name="ID" />
<FieldRef Name="LinkFilename" />
</ViewFields>
</soap:viewFields>
This works for me to exclude the ows_MetaInfo field:
<soap:GetListItems>
<soap:listName>{....}</soap:listName>
<soap:viewFields>
<ViewFields Properties="True">
<FieldRef Name="*"/>
<FieldRef Name="MetaInfo"/>
</ViewFields>
</soap:viewFields>
</soap:GetListItems>
See also http://msdn.microsoft.com/en-us/library/dd964860(v=office.12).aspx
There are no way to remove this field from the output, or at least none that I've found.
The MSDN documentation says that even if you set the IncludeMandatoryColumns to false, it will returns some mandatory fields.
I think your best option here is to fill a bug report to Microsoft, saying that invalid characters are put inside the ows_MetaInfo field.
Another thing you can try, but I don't know if it will resolve the problem it setting the Properties attribute of the ViewFields element to TRUE.
<ViewFields Properties="TRUE">your fieldrefs</ViewFields>