Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: patrice on January 11, 2006, 01:34:29 pm
-
Hello,
I would like to read the rtf stream from a document artifact (model document) by programmation in c# to include this content in a winword document.
How it's possible ?
???
-
Please help me !!!! ??? :-[ ???
I can read the content ( by xml) but the content is in format '.zip' . And after, I don't know the format (.dat in the .zip) (internal, ? ole? )
if (_elem.Type=="Artifact")
{
EA.Project proj=(EA.Project)rep.GetProjectInterface();
string test=proj.GetElement(proj.GUIDtoXML(_elem.ElementGUID));
//test=proj.GetElementProperties(_elem.ElementGUID);
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(test);
XmlNodeList oNodes;
XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);
nsmgr.AddNamespace("UML","omg.org/UML1.3");
XmlElement root = xmlDoc.DocumentElement;
oNodes=root.GetElementsByTagName("UML:TaggedValue");
//oNodes=root.SelectNodes("//@tag='isSpecification'",nsmgr);
String val="";
foreach (XmlNode oNode in oNodes)
{
try
{
if (oNode.Attributes["tag"].Value=="modeldocument")
{
val=oNode.InnerText;
}
}
catch
{
}
}
System.Windows.Forms.MessageBox.Show(val);
byte[] valbase10= System.Convert.FromBase64String(val);
System.Text.ASCIIEncoding ascii = new System.Text.ASCIIEncoding();
// Write out the decoded data.
System.IO.FileStream outFile;
try
{
outFile = new System.IO.FileStream("d:\\test.zip",
System.IO.FileMode.Create,
System.IO.FileAccess.Write);
outFile.Write(valbase10, 0, valbase10.Length);
outFile.Close();
}
catch
{
}
}
-
Hi,
unfortunately I understand that not completely. Why do you create a ZIP file? A simple way is: Write the data in a XML-File. The data can be transmitted by a XML document to Word via a XSLT-Transformation
Oliver :)
-
Hello,
No, it's the content of a 'document artifact' (or linked document ) which is stored in an internal format compressed ( zip) and converted in base64 in the XML.
My code is not very clean but it was to try
:-/ :'(
-
Hi,
Let's take a review of your code
1. You create a new ZIP File called test.zip (System.IO.FileMode.Create)
2. You have (only) Write-Permissions to test.zip (System.IO.FileAccess.Write)
3. You want read the content of test.zip (System.IO.FileMode.Open or System.IO.FileMode.OpenOrCreate)
4. You must have Read-Permissions (System.IO.FileAccess.Read or System.IO.FileAccess.ReadWrite)
So the code cannot function
Oliver :)
-
hi patrice !
if you don't need programmation, you can use "linked documents" to include some RTF document in a EA generated RTF documentation
just look at my answer on the subject "Linked Files in RTF Documentation "
joel