converting schema in XML to XSD for visual studio - 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

Related

Tableau - YML file as data source

I have a .yml file that contains some data the I need to use in my Tableau dashboard. I didn't see that Tableau can directly use .yml as a data source (as it uses .xls, etc). Does that mean do I need to convert my .yml to something supported by Tableau, or are there any other standard/more appropriate ways to achieve this?
Thank you.
if your YML file contains data then you can add it as a text file. I added the file as a "TEXT" file and it displayed the data correctly

The document \"<?xml version='1.0'?>\\n\" does not have a valid root

I am new to parsing the xml in the ruby and I am stuck with an issue. I'll try my best to explain.
I get the below response from an api
"PK\x03\x04\x14\x00\b\b\b\x00,\x18ET\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1D\x00\x00\x00"
I believe it is .tds format.
I am trying to parse it into a valid xml so this is what I tried.
xml = Nokogiri::XML(response)
which gives me #<Nokogiri::XML::Document:0xf744 name="document">
Then I tried to do Hash.from_xml(xml.to_xml)
But this throws error The document \"<?xml version='1.0'?>\\n\" does not have a valid root
Any idea what am I missing here?
This string starts with "PK", which are initials of Phil Katz, author of the ZIP format. Which means it's a ZIP file. There are certain formats that are ZIP files, but actually follow some further structure conventions, like Java JAR files, but also all OpenDocument formats like .ods, .odt and all MS Office Open XML formats.
Since you are probably expecting an .ods file... While you could unzip it and then use Nokogiri to parse the XML, there's a better way to proceed.
There's an interesting Gem called Roo, that supports all most common spreadsheet formats and produces a nice Ruby API to deal with them: https://github.com/roo-rb/roo
I would recommend you to save the string to a temporary file and then open it with Roo.

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 import XML file in to Dynamics AX 2012?

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

Is Isolated Storage Always Necessary?

I see alot of examples on how to write data from an app to a file then put it in isolated storage. I do not want to write any data to my xml file, I just simply want to save it into isolated storage then query it later.
A few simple questions
Someone have code on how to put an existing xml file into isolated storage. Also since I am not writing to this file, do I need isolated storage still? Can I just add the xml to my project and use Linq to xml to open it query it and close it on a button click?
I wanna query the xml through my application in the background. I see alot of examples on serializing, do I need to do this? Can I just open the xml file and use linq to xml to query the data?
Can I just do this, set bbxml.xml to Content and forget about isolated storage and just do this?
using (XmlReader reader = XmlReader.Create("bbxml.xml"))
{
XDocument xml = XDocument.Load(reader);
//query xml....
}
Include the XML file in your project files in Visual Studio, then in the Properties window make sure Build Action is set to Content and Copy to Output Directory is set to Copy always or Copy if newer. This will include the file in the output XAP file.
To access this file in code use:
XDocument doc = XDocument.Load( "path/to/my/file.xml" );
Of course, it doesn't have to be XDocument, you can use any XML reader class similarly.

Resources