InfoPath: Duplicate Attribute error

“The formula contains one or more errors.
Duplicate attribute”

I got it when trying to add ,xsl as Data Connections to InfoPath then add new Rules to controls. Following this guide. It’s resolved the problem

http://www.softobject.com/sites/Blog/Lists/Posts/Post.aspx?ID=4

DUPLICATE ATTRIBUTE ERROR:

This happens when a XSL file is added to the form as 2ndary data source.  The namespace in the XSL conflicts what’s in Form’s ns. 

RESOLUTION:

Do not add XSL as 2ndary data source.  Instead add it as form’s Resource File.  Change your code that might be doing the XSLT transform to load the XSL manually.  This fixes it as charm!

Work around code instead of havinf XSL as a secondary data source

WITH XSL AS SECONDARY DATA SOURCE, YOU COULD HAVE DONE SOMETHING LIKE THIS:

custom.HTMLDocument.body.innerHTML = thisXDocument.DOM.transformNode(thisXDocument.GetDOM("SummaryReport"));

NOW SINCE THAT CAUSES NAMESPACE CONFUSION/CONFLICT, DO THE XSLT LIKE THIS:

IXMLDOMDocument XSLTFileDOM = thisXDocument.CreateDOM(); 
XSLTFileDOM.async = false; 
XSLTFileDOM.validateOnParse = false; 
XSLTFileDOM.load("SummaryReport.xslt"); 
custom.HTMLDocument.body.innerHTML = thisXDocument.DOM.transformNode(XSLTFileDOM);

-DANIEL

It work for JScript. But C#, I don’t get the solution yet.

This Post Has 0 Comments

  1. Quang

    After asking someone over Internet. I found the solution for it. Following the guide from Jimmy http://www.infopathdev.com/forums/p/1641/46072.aspx, It work well. Here are complete codes for implementing transformation from from Resource FilesXslCompiledTransform trans = new XslCompiledTransform();Stream xslTemplate = this.Template.OpenFileFromPackage("DNTN_Temp.xsl");XmlReader xslTemplateReader = XmlReader.Create(xslTemplate);trans.Load(xslTemplateReader);XmlTextWriter myWriter = new XmlTextWriter(resumeFile + "\\\\" + filename, null);trans.Transform(this.MainDataSource.CreateNavigator(), null, myWriter);myWriter.Close();

  2. Macie Karagiannes

    Nice post. I was checking constantly this blog and I am impressed! Extremely helpful information specially the last part I care for such information a lot. I was seeking this particular information for a long time. Thank you and best of luck.

  3. wojtek

    After lookin for the solution few days I’ve finally found your post. Thank you very much.

  4. Hassib

    Please help me to create a button that delete all feild was writted (AS Clear Button )

    Can you provide us a code that delete all feild was written on one click ???

Leave a Reply