I am having xml something like this with nested tags.
<content level="2">
<data>abc</data>
<content level="3">test3</content>
<content level="2">test2</content>
<content level="4">test4</content>
</content>
Irrespective of parent/child tags I want to split xml based on attribute value. i.e I want xml from level 2 to next level 2 as one chunk and remaining child tags as another chunk. my output should be something like below. Is it possible?
<content level="2">
<data>abc</data>
<content level="3">test3</content> -- is one chunk
and
<content level="2">test2</content>
<content level="4">test4</content> -- is another chunk
I tried XPATH with [#level=2] but unfortunately for first chunk it is giving total xml as parent tag contains whole content but I don't want it, i would like to extract only level to level.
I also tried with vtdnav.getContentFragment byusing offset and length and it is still same case where I am getting whole xml as one chunk.
Related
I'm trying to use MSBuild items to list the number of wildcard paths that can be evaluated in relation to a as-yet-unknown base path. As such, I'd like to be able to write:
<Item Include="Content\**\*.js" />
But not evaluate that as a path, but instead add it as a simple item whose %(Identity) is still the string "Content\**\*.js".
Is this possible in MSBuild?
As you have discovered, the item identity needs to be escaped. MSbuild has intrinsic functions to do this easily so you don't need to look up every character:
<ItemGroup>
<Item Include="$([MSBuild]::Escape('Content\**\*'))" />
</ItemGroup>
As is often the case, I discovered the answer immediately after posting.
As per MSBuild Special Characters, I need to escape the asterisk as %2A
Assume the following ItemGroup structure:
<ItemGroup>
<BinaryFiles Include="C:\">
<Binary>a.dll</Binary>
<Binary>b.dll</Binary>
</BinaryFiles>
<BinaryFiles Include="D:\">
<Binary>my.ddl</Binary>
</BinaryFiles>
</ItemGroup>
I need to flatten this to a string like this:
C:\a.dll;C:\b.dll;D:\my.dll
How would I do that? If it's not possible, is there a better way to do it?
A metadata value can have only one value. Multiple definitions and updates will override the value, so the "C:\" item will only have b.dll as Binary metadata.
If there is only one element in the metadata then #(BinaryFiles->'%(Identity)%(Binary)') would yield the result you wanted.
However, since you are using file based logic, you are better off using a BinaryFiles item for each item:
<BinaryFiles Include="C:\*.dll" />
<BinaryFiles Include="D:\*.dll" />
This will scan for all the dll files. You can even use D:\**\*.dll to scan recursively. Then you can use #(BinaryFiles->'%(FullPath') to get the list of all absolute paths.
Example I have an input xml,
<root>
<first>
<a>2</a>
</first>
<first>
<a>3</a>
</first>
<first>
<a>4</a>
</first>
</root>
That should be mapped to,
<root>
<a>2</a>
<a>3</>
<a>4</a>
</root>
I already have output xsd defined that is derived from second xml above but I don't see the mapping in my target because it is one level.
First xml has 3 level and second one is 2 level. So I could not map the child element mapping.
Look at the Branch tangs in the attached image.
You just need to set a mapping where for each input.first -> for each input.a create a output.a.
This is doine using the element mapping controls at the top center (over the lines).
We are using the newest WCF dlls (5.6.1) to implement OData Client. We send a request to a service and we are supposed to get multiple, various entries. Unfortunately, something goes wrong and in the response we are getting the correct count of entries, which are incorrectly duplicated (The entry which is the last one is repeated by the count of entries). When the url, which is sent to the service, is executed in browser the entries in response are correct - every entry is different. The same situation is when in linq query I select only some of the columns by new{x.column1, x.column2} - every entry is different.
This is part of the response from browser:
<entry>
<id>...</id>
<title type="text">...</title>
<updated>2014-05-22T08:44:46Z</updated>
<category term="GET_AVG_CONS.Y_AVG_CONS_YEAR" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
<link href="Y_AVG_CONS_YEAR_COLLECTION(Customer='1000000167',CompCode='DE0J')" rel="edit" title="Y_AVG_CONS_YEAR"/>
<content type="application/xml">
<m:properties>
<d:BpCat/>
<d:Cusvalsg/>
<d:Salesorg/>
<d:Flag/>
<d:Calmonth>201309</d:Calmonth>
<d:BpCatX/>
<d:CusvalsgX/>
<d:SalesorgX/>
<d:FlagX/>
<d:CalmonthX/>
<d:Customer>1000000167</d:Customer>
<d:ProdHier/>
<d:CompCode>DE0J</d:CompCode>
<d:HierX/>
<d:OrdMeth/>
<d:Nptotcap>2200.000</d:Nptotcap>
<d:Type/>
<d:Code>000</d:Code>
<d:Message/>
</m:properties>
</content>
</entry>
<entry>
<id>...</id>
<title type="text">...</title>
<updated>2014-05-22T08:44:46Z</updated>
<category term="GET_AVG_CONS.Y_AVG_CONS_YEAR" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
<link href="Y_AVG_CONS_YEAR_COLLECTION(Customer='1000000167',CompCode='DE0J')" rel="edit" title="Y_AVG_CONS_YEAR"/>
<content type="application/xml">
<m:properties>
<d:BpCat/>
<d:Cusvalsg/>
<d:Salesorg/>
<d:Flag/>
<d:Calmonth>201310</d:Calmonth>
<d:BpCatX/>
<d:CusvalsgX/>
<d:SalesorgX/>
<d:FlagX/>
<d:CalmonthX/>
<d:Customer>1000000167</d:Customer>
<d:ProdHier/>
<d:CompCode>DE0J</d:CompCode>
<d:HierX/>
<d:OrdMeth/>
<d:Nptotcap>220.000</d:Nptotcap>
<d:Type/>
<d:Code>000</d:Code>
<d:Message/>
</m:properties>
</content>
</entry>
This is part of the response from linq query selecting all colums:
And this is the response when I select only some of the columns in linq query:
Does anyone know what might be the problem?
#Zoe
The request which is sent by browser as well as from application, which results in duplicated entries, is the same:
IPaddress:port/something/GET_AVG_CONS/Y_AVG_CONS_COLLECTION()?$filter=Customer eq '1000000167'.
The request from application, which results in correct entries is:
IPaddress:port/something/GET_AVG_CONS/Y_AVG_CONS_YEAR_COLLECTION()?$filter=Customer eq '1000000167'&$select=Calmonth,Nptotcap.
#christiandev
I don't understand your question. I'm using linq query. Before the query is executed, there are no entries in collection. After the execution, they are already duplicated.
I have created a custom .targets file with following item group
<ItemGroup>
<AvailableItemName Include="Foo" />
</ItemGroup>
I can access that collection or list with #(Foo) and I get 'Item1.txt;Item2.txt'
If I do %(Foo.FullPath) I get 'C:\projectfolder\Item1.txt'
How do I use both the meta data tag %, and the "collection" tag # together to get
'C:\projectfolder\Item1.txt;C:\projectfolder\subfolder\Item2.txt' ?
#(Foo->'%(Foo.FullPath)')
You can read more MSBuild Transforms