Vlax
Vlax

Reputation: 1527

Appending namespace prefixed tags with Altova XMLSpy 2012 generated code (Version 2007r3)

Apparently there's a bug in the latest version of the code generator of Altova XMLSpy 2012 sp1 when working with XML files that use a Tags Namespace Prefix you will find that the generated XML is missing the prefix. After trying the different versions and poking around I found a fix for that problem, basically you have to replace the content of following method (line 110 in typebase.cs):

public XmlNode CreateElement(MemberInfo member) 

with

return XmlTreeOperations.AddElement(node, member);

That should do the magic.

Can someone confirm this?

Note: I'm posting this here because it seems that Altova has shut down their support forum and there are not responding to email enquiries...

Regards and hope this helps somebody.

Vlax

Upvotes: 1

Views: 1119

Answers (2)

Mitja Gustin
Mitja Gustin

Reputation: 1781

You can also modify constructor for creating element:

public XmlNode CreateElement(MemberInfo member)
{
    string prefix = member.ContainingType.Namespace.prefix;
    XmlDocument doc = node.OwnerDocument;
    if (doc == null)
        doc = (XmlDocument)node;
    XmlNode child = doc.CreateElement(prefix, member.LocalName, member.NamespaceURI);
    node.AppendChild(child);
    return child;
}

However, you still need to remove namespace uri from the generated elements. Possible solution is here: clear namespaces from xml

Upvotes: 1

Saroop Trivedi
Saroop Trivedi

Reputation: 2265

You need to change into SPL directory for customize the auto generated code. Below is the path of SPL directory. Before modify the SPL directory. Please study the SPL first.

C:\Program Files\Altova\XMLSpy2012\spl

1. Study SPL directory first.
2. Select your lang in which you work. 
Suppose you work in c# then modify the files inside the  below path
C:\Program Files\Altova\XMLSpy2012\spl\cs\MapForce

Upvotes: 0

Related Questions