How to import XML file in to Dynamics AX 2012? - dynamics-ax-2009

I am wondering which is the best way to import XML file like (purchase orders) into Dynamics AX?

There are a few examples available via searching the web...
Axaptapedia suggests two libraries:
XMLDocument class, code example
SAXReader class, which may be better for parsing large XML files

Here are good examples of how to
Read XML
Create XML

It also depends on the size of the XML, we have seen large file sizes that caused the XMLDocument class to consume too many memory because it loads the XML in memory.
You could also use the XMLTextReader if you need performance and you don't need schema validation.
If you do need schema validation, you would have to stick to XMLDocument. (check out this article
Check out this article on codeproject that explains XMLTextReader in full detail.
http://www.codeproject.com/Articles/15452/The-XmlTextReader-A-Beginner-s-Guide
Also, I was wondering, do you have ownership of the application that produced the XML file? If it is something you have in your own hands, you might consider creating an AIF Custom service and call this from your other application. (But I guess you are not the owner of the application producing the XML file you want to import.)

Related

I am looking for code policy enforcement tool for xml and Python

I have projects that are developed with xml and python code mostly (Odoo modules). There is a bit of .po files for translation and csv fields for data.
I would like to enforce specific policies in xml files, for example:
No duplicate id attributes.
A specific attribute must be present if child elements contain a specific tags.
On python, I want to enforce rules like:
Look for SQL queries, and make sure that they use specific parameter methods to prevent SQL injection
Follow a specific naming convention
Some attributes are required in classes that inherit a specific class
I hope that the idea is clear.
Is there any open source solution for this? Preferably linked with github and checks on every commit!
I found a python package made specifically for this, pylint-odoo, here.
It can also be installed with pip install pylint-odoo.
An example .pylintrc config file can be found at the web OCA module, here. They also have another file named .pylintrc-mandatory.
There is even a warning for duplicate xml id attribute W7902.

How to read excel file tibco activities?

I have a requirement to read excel file using tibco palettes.Can any body please throw some lights regarding this. I am basically new to this tibco BW. Please tell me what steps should I follow?
I am assuming you are not referring to CSV files, for which you could use the File Read and Parse activities of BW.
If you want to parse or render a multi-worksheet workbook, you can try publicly available API's such as Apache's POI or commercial API's such as from Aspose to cut your own Java based solution. Then you can use the Java Code or general Java activities to embed and use that code.
And then there's another ready-to-use option available from us: an Excel Plugin for TIBCO BusinessWorks, if you wish to leverage all built-in features of BW (XPath mapping, etc) when parsing or rendering your Excel.
Edit 1:
As per your comment, you can also try the following steps, if you are looking for a more homegrown solution.
Based on one of the (public/commercial) libraries above you can write generic Java Code to parse each cell of each row of each sheet of the workbook. Output should be an XML string. Then create an XSD to match your output. It is at your discretion, which information of the cell you want to read from the workbook - you already are aware of the complexity of the API, I am sure.
Create a BW (sub)process that calls your code from a Java activity, use Parse XML to parse your XML string result into you XSD structure. Configure the End activity to use your XSD and map (copy) your Parse XML result into the End activity.
Then wrap this subprocess into a Custom Activity (General Activities Palette). Create a Custom Palette and now you can re-use what you did in many other BW projects. The path to the custom palettes can be found in TIBCO Designer - Edit- Preferences - General - User Directories
If you add Error Output schemas, you will also get typed error outputs from that custom activity.
HTH,
Hendrik

Is there any tool to generate a labels.rdf file?

Examining the 404 errors for my website I noticed requests for a "labels.rdf" file. After some digging I think I understand what it is and want to create one for my website. But I don't really understand how to generate it. Is there any tool or a generic file that I can use?
Thanks
RDF is not just one format, but a collection - most likely it's expecting RDF/XML.
IMHO the esiest thing to do is create the data you need in a format called Turtle (http://www.w3.org/TeamSubmission/turtle/) - there's lots of tutorials online, then convert it to RDF/XML with a tool, such as rapper (http://librdf.org/raptor/).
You will need to know a bit about the RDF data model though, and what the labels.rdf file is trying to express.

converting schema in XML to XSD for visual studio

Note, I am not trying to generate the schema for an XML file from the file. There is plenty about that on the web. Kind of a waste--how can a file fail validation if the validator was generated from the file it's validating?
Anyway, I want to test an SSIS component that requires a configuration file in XML (not XSD) to tell it how to parse another input file (this input is also not XML).
The provider of this component says we have to create our own config xml files. I would like to use Intellisense to help do that. There is a schema for these config files, but it is in XML.
Is there a way to create a schema from an XML file that represents the content of that file, not the structure?
Example is in second paragraph. Anyway, it turns out there is a way, and it's embarassingly simple.
Just rename the file from whatever.xml to whatever.xsd

Programatically retrieve an attachment stored on a note on a CRM 4.0 entity

How would you suggest working with files that is stored on the note of a entity in Crm. Could you write a generic method that will enable you to access any type of file? Or would it be better to have a method for dealing with each type of file?
For example, we are going to be saving a mix of swf files and xml files on the entity, so would it make sense to have a method each for example:
GetXmlFilesOnAccount(accountid)
GetSwfFilesOnAccount(accountid)
When you upload an attachment to CRM the mimetype is also saved as part of the record information.
The following link contains a nice example of how to download the attachemt using a single method. http://crmscape.blogspot.com/2009/10/ms-crm-40-sending-attachments-to.html
The post is missing the actual query needed to retrieve the annotations but you can tell what columns are required from the method signature.
My suggestion using your methods:
* GetXmlFilesOnAccount(accountid)
* GetSwfFilesOnAccount(accountid)
Retrieve account activitypointers by regardingobjectid(in your case accountid guid)
Loop through returned activitypointers
Get attachments for each activitypointer (activitypointer.activityid = activitymimeattachment.activityid)
Store attachments (disk, etc)
You don't even need two methods. You can retrieve all attachment file types for a given note (annotation) with a single method.
Hope this helps.
I recently started an Open Source Project on CodePlex to accomplish exactly that. Feel free to check out the Project's Web Page at:
http://crmattachdownload.codeplex.com/
You can also view the source code under the "Source Code" tab of that same page.
Pete

Resources