Link to home
Start Free TrialLog in
Avatar of Roger
RogerFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Importing third party XML data into MS Visio

I type text into shapes in Visio drawings derived from Templates. Now I want to add automation,  by importing text automatically from various third party XMLs. Can I and ought I import the data fields of the 3rd party into MSOffice XML derived from my drawing template? I use Visio 2010 Premium.

This would involve a learning curve on my part. I am aware that third party XML should be established as well formed, and they will not comply with the MS schema.

Can you recommend procedures/applications whereby I can:
- Select, for each relevant data field in Visio MSOffice XML, which data field should be imported from the third party XML?
- Make a sensible shell in vba to automate the import process, so that a series of third party XML specifications of the same structure but different content can be imported into different instances of a Visio template.

If available, on the grounds of cost, freeware / vba code would be an attractive first step, to gain a working model in the first instance. However, a commercial application would be of interest if it can be used 'out of the box'.

Thanks

Kelvin4
Avatar of Roger
Roger
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

Thanks for your advice:

-Sample of third Party XML is attached in the file. Reference to XML Schema is included in <MyDoc>.  I had thought that XML validation would be carried out in Excel. The size of the third party XML file could be much larger than the demo of 28 lines. For example there are four elements: "Text1 identifier" ... "Text4 identifier", and could be many more. But the overall complexity of the file is not great.

- Visio MSOffice XML  I don’t have a sample of this run off and annotated at present. Well over 95% of the data in the Visio XML file will not be copied from the third party XML, but generated de novo from within the Visio file.

- DATA IMPORTED from Third Party file will be Text and numbers, but mainly text.

Text is not currently limited in length, but I don’t anticipate lengths in excess of 1500 characters.

Some text will contain HTML tags. I can parse those tags so that the formatting they specify is viewable in Visio.shape.text, by creating the appropriate data in the shape character file (in the shapesheet character section).

I hope this is useful information.
Thanks,
Kelvin
Sample-xml-for-EE-04032012.docx
Avatar of aikimark
I looked at the XML in the Word document, using XML Notepad (a handy free tool from Microsoft).

I had to clean it up in a few places, specifically:
* Word smart quotes used instead of Chr(34) ASCII quote characters a couple of times
* Missing space before xsi:schemaLocation= and method1=
* space in closing tag </rInput> between the slash and the "r"

Cleaned up version of the code:
<MyDoc xmlns="Thisxmlns" xmlns:xsi="ThisXMLSchema-instance" xsi:schemaLocation="ThisSchema.xsd" identifier="MyID" title="MyTitle" method1="false" time="false">
  <rInput identifier="myInput" type="single" baseType="identifier">
    <cInput>
      <value>TextZ</value>
    </cInput>
  </rInput>
  <output identifier="myOutput" type="single" dataType="integer">
    <defaultValue>
      <value>0</value>
    </defaultValue>
  </output>
  <docBody>
    <p>Look at the text in the picture.</p>
    <p>
      <img src="images/myGraphic.png" alt="image title" />
    </p>
    <theTexts responseIdentifier="RESPONSE" param1="true" param2="1">
      <prompt>What does it say?</prompt>
      <Text1 identifier="myTextIdentifier1">MyText1</Text1>
      <Text2 identifier="myTextIdentifier2">MyText2</Text2>
      <Text3 identifier="myTextIdentifier3">MyText3</Text3>
      <Text4 identifier="myTextIdentifier4">MyText4</Text4>
    </theTexts>
  </docBody>
  <VisioProcessing template="ThisVisioTemplate" />
</MyDoc>

Open in new window


If you are editing this XML, use XML Notepad, Notepad, or some editor that will will not introduce changes that invalidate/malform the XML.
Once the XML was 'cleaned' I was able to open it with Excel without any problems.

I would like to see the XML without your editing it.  Please upload your XML file.
Avatar of Roger

ASKER

Thank you for the trouble taken; my effort to simplify the text has been unhelpful. Attached is the original, but I added spaces as you did, as XML Notepad reported the lack of spaces that you identified.

XML Notepad also reported the use of incorrect quote marks, but I could not identify them.

The material comes from the qti standards for setting computer-based questions, and is a useful place to start experimenting with the import of third party XML.

I hope this is helpful
Thanks!
EE-XML-unedited-example-corrects.txt
The vendor is producing malformed XML.  The sample you posted contained the following incorrect closing tag:
</ responseDeclaration>

Open in new window


Such errors can be easily fixed by some simple editing (manual or programmatic), replacing all "</ " with "</" until no more are found in the file.

I didn't get any other error messages when opening the file with XML Notepad.  It did take a long time to open the file because of the xmlns: links.  I assume your open times are much faster.
Avatar of Roger

ASKER

Yrs, thanks, the corrected XML file opened immediately in XML Notepad.
ASKER CERTIFIED SOLUTION
Avatar of aikimark
aikimark
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Roger

ASKER

Thanks. You have looked at my files, corrected them, got me started  with XML Notepad, and aware of malformed third party XML. I will sign this question off as Solved and ask a second question, to address the problem of importing selected well-formed third party XML data into certain data fields of MS Office XML for Visio.

I have run off some XML from a small visio test file, with one data field of interest. The XML data field into which I want to export third party data is visible in XML NotePad.  

If I forward these in a new question, would you be in a position to help me tackle the data transfer method?

Kelvin
Avatar of Roger

ASKER

Thanks for the start. Kelvin
@Kelvin

>>If I forward these in a new question...
I'm currently monitoring http:/Q_27661631.htm
However, I don't have Visio, so I can't help you as a subject matter expert with that part of your problem.