I have one requirement, I am new to XSLT language so I am looking for your help for my below requirement.
Below is the input xml payload
<?xml version="1.0" encoding="UTF-8" ?>
<ns0:sendfile xmlns:ns0="namepsace here">
<Delivery>
<IssueDateTime>2016-05-24T09:25:19z</IssueDateTime>
<Item>
<order>
<orderChar>
<orderName />
<orderVal />
</orderChar>
<orderInfo>
<Product />
<Batch />
<Qty />
<UOM />
</orderInfo>
</order>
</Item>
</Delivery>
so in the file orderchar node and orderInfo node will repeat multiple times based on that in receiver structure 2 nodes should repeat. for example
orderchar segment is repeating 20 times, in receiver also E1ADRM segment should repeat same number of times.
order info also same case in receiver E1DRM segment should repeat same number of times.In case any of the node will not come in receiver also the segment should not populate.
I think we can do this some value of select with that syntax. could you please help me on this.
I tried with below code and able to generate the node. but when repeated nodes are coming the repeated receiver nodes are not populating.
<ns0:if test="count(./order/orderChar)!=0">
<E1EDL12 SEGMENT="1">
<ATNAM>
<ns0:value-of select="./orderChar/orderName"/>
</ATNAM>
<ATWRT>
<ns0:value-of select="./orderChar/orderName"/>
</ATWRT>
</E1EDL12>
above code tried for only for one segment.could you please suggest what modification I have to do to populate multiple times.
Regards,
Janardhan
You really haven't made your requirement very clear, but my guess would be that you want something like:
<xsl:for-each select="orderChar">
<ATNAM>
<xsl:value-of select="orderName"/>
</ATNAM>
<ATWRT>
<xsl:value-of select="./orderChar/orderName"/>
</ATWRT>
</xsl:for-each>
Related
I have just recently started using .Net MAUI. But now I'm wondering how to use a piece of code, e.g. a self-made navigation bar on all my pages, because it doesn't make sense to write the same code on all 10 pages. I like to know if there is a way to create a component that can be reused like in React or Angular?
PS: This question is not specific to a navigation bar but to the general reuse of code in .NET MAUI.
I have so far watched various videos & articles on this topic, however, it is more about custom controls and did not help me. Most articles corresponded to what was conveyed in this video. I also came across this article, but it didn't help me either.
Thanks for your help :)
First, you can create a new .xaml file named Name.xaml. You can write some codes in it.
<?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CusComponents.Name">
<ContentView.Content>
<StackLayout Padding="10">
<Label Text="Name" FontAttributes="Bold" />
<Label Text="First name" />
<Entry x:Name="FirstName" Placeholder="First name" />
<Label Text="Last name" />
<Entry x:Name="LastName" Placeholder="Last name" />
</StackLayout>
</ContentView.Content>
</ContentView>
Second, you can use it in the page you want like this. You need to add an xmlns reference to the top of the XML file– this is like a using statement in a C# file. Using the namespace structure for the sample project, this will be xmlns:custom_components="clr-namespace:CusComponents".
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:custom_components="clr-namespace:CusComponents"
x:Class="CusComponents.MainPage">
<custom_components:Name />
</ContentPage>
Here is the view of the code:
I have an XML from which I want to filter the Title and EMail.
This is the XML:
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xml:base="https://mysite/vis/_api/">
<id>https://mysite/vis/_api/Web/GetUserById(1284)</id>
<category term="SP.User" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<link rel="edit" href="Web/GetUserById(1284)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Groups" type="application/atom+xml;type=feed" title="Groups" href="Web/GetUserById(1284)/Groups" />
<title />
<updated>2020-01-15T18:23:48Z</updated>
<author>
<name />
</author>
<content type="application/xml">
<m:properties>
<d:Id m:type="Edm.Int32">1284</d:Id>
<d:IsHiddenInUI m:type="Edm.Boolean">false</d:IsHiddenInUI>
<d:LoginName>i:0#.w|opmain\xespsa</d:LoginName>
<d:Title>Alex, Johnson</d:Title>
<d:PrincipalType m:type="Edm.Int32">1</d:PrincipalType>
<d:Email>Alex.Johnson#stackoverflow.net</d:Email>
<d:IsSiteAdmin m:type="Edm.Boolean">false</d:IsSiteAdmin>
<d:UserId m:type="SP.UserIdInfo">
<d:NameId>s-1-5-21-1377870913-3677095212-3270174719-20443</d:NameId>
<d:NameIdIssuer>urn:office:idp:activedirectory</d:NameIdIssuer>
</d:UserId>
</m:properties>
</content>
</entry>
I tried using the XMLFILTER function from Excel, but my XPath is wrong:
=XMLFILTERN(E4;"//content/title[1]")
How can I get the correct xpath in this case since Title is inside content?
TLDR/from comments: Excel doesn't care about namespaces. Reuse the prefixes in the source XML and ignore the default namespace...
//content/m:properties/d:Title
It's probably because your XML has namespaces.
content is in the default namespace http://www.w3.org/2005/Atom.
properties is in the namespace http://schemas.microsoft.com/ado/2007/08/dataservices/metadata bound to the prefix m.
Title is in the namespace http://schemas.microsoft.com/ado/2007/08/dataservices bound to the prefix d.
I'm not sure how Excel/XMLFILTER handles namespaces in XPath (hopefully someone answers that does), but ideally you'd bind those namespace uris to prefixes and use the prefixes in the XPath.
If you can't, you'll probably have to resort to using local-name()...
//*[local-name()='content']/*[local-name()='properties']/*[local-name()='Title']
If there's a possibility of elements with the same local name, but different namespaces (and you need to distinguish between them), you can also use namespace-uri()...
//*[local-name()='content' and namespace-uri()='http://www.w3.org/2005/Atom']/*[local-name()='properties' and namespace-uri()='http://schemas.microsoft.com/ado/2007/08/dataservices/metadata']/*[local-name()='Title' and namespace-uri()='http://schemas.microsoft.com/ado/2007/08/dataservices']
Of course this is all assuming that those two XPath 1.0 functions are supported.
For the xPath argument in Excel, you should use the namespace:
The full path:
//content/m:properties/d:Title
//content/m:properties/d:Email
In your particular instance, you can more simply use:
//d:Title
//d:Email
I'm working on a stock control system and the client wishes to export their listings to their Amazon Marketplace account. So far, I've come across the SubmitFeed endpoint. However, all of the examples I look at only show an example of submitting a single product.
As Amazon’s documentation states you can only have so many active feeds at a time, I would have thought you would have been able to send multiple products in a single feed so you're not exhausting the feed limit, as I imagine power sellers will want to list dozens—maybe even hundreds—of products at a time.
I'm currently sending an XML documentation that contains one <Message> element, i.e.
<?xml version="1.0" encoding="UTF-8"?>
<Message>
<MessageID>1</MessageID>
<OperationType>Update</OperationType>
<Product>
<SKU>56789</SKU>
<StandardProductID>
<Type>ASIN</Type>
<Value>B0EXAMPLEG</Value>
</StandardProductID>
<ProductTaxCode>A_GEN_NOTAX</ProductTaxCode>
<DescriptionData>
<Title>Example Product Title</Title>
<Brand>Example Product Brand</Brand>
<Description>This is an example product description.</Description>
<BulletPoint>Example Bullet Point 1</BulletPoint>
<BulletPoint>Example Bullet Point 2</BulletPoint>
<MSRP currency="USD">25.19</MSRP>
<Manufacturer>Example Product Manufacturer</Manufacturer>
<ItemType>example-item-type</ItemType>
</DescriptionData>
<ProductData>
<Health>
<ProductType>
<HealthMisc>
<Ingredients>Example Ingredients</Ingredients>
<Directions>Example Directions</Directions>
</HealthMisc>
</ProductType>
</Health>
</ProductData>
</Product>
</Message>
The <MessageID> element suggests I'm able to specify multiple “messages” in a feed, but I'm not sure on the syntax as I would expect the <Message> to be inside a <Messages> element, in which I could specify multiple messages.
How can I specify additional messages and thus additional products? Or am I going down the wrong track?
You need to send multiple Messages in one AmazonEnvelope:
<?xml version="1.0" encoding="utf-8"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>MERCHANTID</MerchantIdentifier>
</Header>
<MessageType>Product</MessageType>
<Message>
<MessageID>1</MessageID>
<OperationType>Update</OperationType>
<Product>
....
</Product>
</Message>
<Message>
<MessageID>2</MessageID>
<OperationType>Update</OperationType>
<Product>
....
</Product>
</Message>
</AmazonEnvelope>
All messages in one feed need to be of the same MessageType (e.g you cannot mix Product messages with Inventory data) and have a MessageID unique to this feed.
I have two (related) questions:
I am having a puzzling problem with the Advanced Find function. I set up the fields I require, both in the criteria and display section and then hit 'Download Fetchxml'. What I end up with is fields that I never asked for. For example, in my advanced find I asked for All Activities. I changed the results to show me only the Date Created, Activity Type, Subject and Regarding fields. The (truncated) generated fetchXML looks like this:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="activitypointer">
<attribute name="activitytypecode" />
<attribute name="subject" />
<attribute name="activityid" />
<attribute name="instancetypecode" />
<attribute name="community" />
<attribute name="createdon" />
<attribute name="regardingobjectid" />
<order attribute="subject" descending="false" />
Why have those extra columns been included? I didn't ask for the 'community' attribute anywhere, for example.
Second question:
What determines the output order of the fields? I ran the above fetchXML through Fetch Tester 3000 (saved my life - thank you!) and the output table bears no relation to the order of the attributes in the xml. This is true also when I use the fetchXML elsewhere.
Thanks in advance for your comments
The FetchXML returned by the button Download Fetch XML is generated internally and in some scenarios it returns extra columns (as you found), for example the primary key field of the entity is always added.
If you remove the additional attributes the FetchXML is still valid and can be executed.
Regarding the order, the tool you used (Fetch Tester 3000) display the fields inside the Table View ordered by their logicalname, inside Dynamics CRM the order of the attributes (subgrids and advanced find results) is defined using another XML definition known as LayoutXML
I'm not sure if it matters, but I'm using BizTalk 2009 to generate the XML.
Is there a way to specify in my XML schema that the generated XML instance should use the target namespace as the default namespace?
If I have an xsd file like this:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://example.com/">
<xs:element name="example">
<xs:complexType>
<xs:attribute name="value" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:schema>
It creates an XML file like this:
<ns0:example value="something" xmlns:ns0="http://example.com/" />
But I want it to create an XML file like this:
<example value="something" xmlns="http://example.com/" />
I know that they're technically equivalent, but the consumers (vendor APIs) are poorly implemented and I'd like to give them what they expect.
I would expect that it depends on the software generating the instance, not the schema. XSD Schema was developed for validation of XML instances against a schema, not for generating instances from it. So it is unlikely to be present explicitly in XMLSchema. The generating tools might, however, use the fact that elements were (un)qualified
elementFormDefault="(un)qualified"
to trigger the prefixing.
Not completely in scope, but the following is worth reading for schema design: http://www.xfront.com/HideVersusExpose.html
One way would be to define a schema without the namespace. Map the BizTalk schema to the newly defined schema without namespace. From a BizTalk viewpoint, you would have a schema which represents the actual contract with the consumers. (i.e. without namespaces) Also, BizTalk uses namespace#rootnodename to define messageTypes. In this example, you would have two schemas
somenamespace#somerootnodename
#somerootnodename
The possible drawbacks of this approach are this would limiting the usage of this schema (#rootnodename) to 1 instance with the BizTalk group.
This is the default behaviour of BizTalk working this XML schemas and, as far as I know, there is no builtin way to change this.
What you really want, however, is that outbound messages conform to a cleaner and more liberal format than what is used by BizTalk. You can do this by using a custom pipeline component (and a custom send pipeline) to process the outgoing message before it leaves BizTalk.
The idea is to change the namespace prefix as part of sending the message outside BizTalk. The transformation happens during the processing of the send pipeline.
Nic Barden has blogged and provided some source code about this here. You can use his sample as the basis for performing replacement of namespace prefixes, rather than replacing namespaces themselves.
I strongly encourage you to check out the whole series of posts he's done about Developing Streaming Pipeline Components. Nic has made an extensive and thorough job of describing all that's needed to author robust and enterprise-class pipeline components.
Part 1
Part 2
Part 3
Part 4
Part 5
The ns0 prefix is added whenever a BizTalk btm maps a message. It shouldn't matter as this is still valid xml, however this could be a problem when sending messages to partners with legacy or incomplete xml parsers.
You can remove the ns0 prefix and instead make ns0 your default namespace on the output message by changing your btm from a visual map to an .xslt map.
e.g. Once you have converted your map to xslt, change the xslt from:
<?xml version="1.0" encoding="utf-16"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
exclude-result-prefixes="msxsl s0"
version="1.0"
xmlns:ns0="http://targetns"
xmlns:s0="http://sourcens"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />
<xsl:template match="/">
<xsl:apply-templates select="s0:FromRoot" />
</xsl:template>
<xsl:template match="s0:FromRoot">
<ns0:ToRoot>
<xsl:for-each select="s0:FromElement">
<ns0:ToElement>
<xsl:value-of select="text()"/>
</ns0:ToElement>
</xsl:for-each>
</ns0:ToRoot>
</xsl:template>
</xsl:stylesheet>
To:
<?xml version="1.0" encoding="utf-16"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var"
exclude-result-prefixes="msxsl s0"
version="1.0"
xmlns="http://targetns"
xmlns:s0="http://sourcens"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />
<xsl:template match="/">
<xsl:apply-templates select="s0:FromRoot" />
</xsl:template>
<xsl:template match="s0:FromRoot">
<ToRoot>
<xsl:for-each select="s0:FromElement">
<ToElement>
<xsl:value-of select="text()"/>
</ToElement>
</xsl:for-each>
</ToRoot>
</xsl:template>
</xsl:stylesheet>
i.e. change the default xmlns and then remove the ns0 prefixes automatically.
A more generic solution is also possible (e.g. similar to Firras' answer here), which could be useful e.g. to place as a send port map to strip out all prefixes from elements. However, one needs to be wary if there are more than one xmlns on the output message!