IMPORTANT:
this is not a Support Forum! Experienced users might answer from time to time questions posted here. If you need a professional and reliable answer, or if you want to report a bug, please contact Altova Support instead.

How to get a namespace prefix in element names instead of URL in generated code Options · View
dev3
Posted: Wednesday, February 28, 2018 5:33:22 AM
Rank: Newbie

Joined: 2/28/2018
Posts: 1
Location: Canada
Hello dear forum members,

We have generated some c# classes from a set of schemas, each using a different namespace.
For example below, lets say that FirstName / LastName types have been defined in a different schema with namespace "http://custom.namespace".

Out of the box we get the xml below, which duplicates "http://custom.namespace" URL in each element like below:

<?xml version="1.0" encoding="utf-8"?>
<Customer xmlns="http://default.namespace">
<ID>123</ID>
<FirstName xmlns="http://custom.namespace">John</FirstName>
<LastName xmlns="http://custom.namespace">Doe</LastName>
</Customer>

What do we need to do in code in order to get "http://custom.namespace" namespace listed in a root element with some prefix and have FirstName / LastName elements use it, so it would look like this:

<?xml version="1.0" encoding="utf-8"?>
<Customer xmlns="http://default.namespace" xmlns:nax="http://custom.namespace">
<ID>123</ID>
<nax:FirstName>John</FirstName>
<nax:LastName>Doe</LastName>
</Customer>

Users browsing this topic
guest

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Use of the Altova User Forum(s) is governed by the Altova Terms of Use.