basquang™ on clouds

August 20, 2009

InfoPath: Duplicate Attribute error

Filed under: InfoPath — basquang @ 5:03 AM

“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.

Advertisements

5 Comments »

  1. 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();

    Comment by Quang — August 21, 2009 @ 2:52 AM | Reply

  2. 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.

    Comment by Macie Karagiannes — June 19, 2011 @ 2:45 PM | Reply

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

    Comment by wojtek — July 12, 2011 @ 2:30 PM | Reply

  4. 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 ???

    Comment by Hassib — March 14, 2012 @ 11:39 PM | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: