Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Removing ns0: prefix from xml output from BizTalk/Logic app XSLT map

Introduction

Xml, which stands for stands for EXtensible Markup Language was designed to describe data and to do that you use tags. It's basic purpose is to focus on what data is  - self decsribing. 

And as we have a provision to add our own tags, it becomes Extensible.

Having this properties makes it very suitable for defining a message (Records, elements and attributes) and exchange it across, also data can be stored in it and can be refered/updated as an when needed (most of the configurations are xml based).

In case of where XML is involved in messaging, it becomes vital to have Namespace as it helps in avoiding element name clashes/conflicts.

A Namespace is a set of unique names. Namespace is a mechanisms by which element and attribute name can be assigned to a group. The Namespace is identified by URI(Uniform Resource Identifiers).

For example, you are dealing with OrderXML and you are receiving multiple OrderXML from different vendors - so how do you differentiate which xml(same structure) is from whom - It is with namespace.


To define xml you use xsd and when you create xsd in BizTalk/Logic app Project(using visual studio) few namespaces automatically gets added, also gets added is Target namespace(identifier - that created xsd belongs to this project ) to say that this xsd belong to it.

default namespaces in xsd

The namespaces which gets added automatically are actually to tell our schema editor that we are referring to definitions in them and it is done with help of namespace prefix - xs and b in above image. And for Target Namespace there is no prefix .

Consider Target Namespace is to schema is what a namespace is to .Net Object. 

Read more about Schema -- BizTalk Server : Deep dive in schema design

How ns0 gets added in output of map using above schema as destination


Now when we do map from one schema to another, we create new xml and to which namespace it
belongs to it gets added and thus you see namespace and it's prefix
 ns0 added in map result

If you see above ns0 gets added in test map result, although there was no prefix associated with TragetNamespace in xsd -- It is the mapper which does it and ns0 is the default prefix.

So if I use xsd having prefix already associated with TargetNamespace  -- Still mapper will add the default prefix ns0.


How to remove default prefix ns0 and have prefix as per our preference


To do this we need to bypass the mapper and for that we make changes in xslt generated
by the mapper.

Right click the map, select debug and you should see the path where xslt is generated,Copy the path.

Now edit the xslt and add preferred prefix and save it
change prefix ns0
You can use saved xslt in Logic app or in BizTalk by setting the custom xslt path and get desired output.

Related Post 

  • Getting Started with Logic Apps - Enterprise Application Integration
  • Getting Started with Logic Apps - EDI X12 Fundamentals
  • Getting Started with Logic Apps - What happened to the Request?
  • Getting Started with Logic Apps - Fundamentals
  • Getting Started with Logic Apps - AS2
  • Getting Started with Logic Apps - XML to EDI X12
  • The provided map definition is not valid
  • Required property 'content' expects a value but got null. Path ''.'
  • Getting Started with Logic Apps - File Routing
  • Installing and Configuring On Premises Data Gateway - By adding user to Active Directory
  • Inserting data in On Premises SQL Database using Logic Apps
  • Inserting Multiple Records In On Prem SQL Using Logic App
  • Check your request parameters to make sure the Path “” exists on your file system

  • EDI X12 Documents List
  • BizTalk Server : Fetching UNB and UNG Segment Values From Interchange Envelope and Mapping
  • BizTalk Server : Fetching UNB and UNG Segment Values From Interchange Envelope and Mapping - Orchestration
  • EDIFACTSegmentValueFetcher


    ServerLess360




    This post first appeared on TechFindings, please read the originial post: here

    Share the post

    Removing ns0: prefix from xml output from BizTalk/Logic app XSLT map

    ×

    Subscribe to Techfindings

    Get updates delivered right to your inbox!

    Thank you for your subscription

    ×