DOORS XML support

1. Does DOORS support XML?
2. Can XML data from MS Word be uploaded to DOORS?
3. If so, what is needed?
SystemAdmin - Wed Apr 28 14:56:08 EDT 2010

Re: DOORS XML support
Mathias Mamsch - Thu Apr 29 04:37:01 EDT 2010

DOORS DXL has integrated perms to read XML (see below). You can use them to parse an XML file and read tags and their attributes. I guess the meaning and the usage of the perms are obvious, they are a simple wrapping of the "MS DOM Document" OLE class. If you want a more complete library to read and write XML you can take a look at the "DXL standard library" on sourceforge. This is an open source project I founded, which is not yet ready to release, but already contains a very functional XML library with a good documentation. Find it here: http://sourceforge.net/projects/dxlstandardlib/.

To answer your second and third question, I guess there are quite some people that already implemented an XML Word import in DXL. However my guess is, that most of these people will not share their code, since they consider it "too valuable" (although they will probably not sell it anyway).

Hope that helps, Regards, Mathias
 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
 

DOM_Document_ getDocumentBuffer_ (DOM_Document_, Buffer&)
string getStringAttribute_ (DOM_Element_, string)
string getElementName_ (DOM_Element_)
string setStringAttribute_ (DOM_Element_, string, string)
void ::do (DOM_Element_&, DOM_Element_, void)
void ::do (DOM_Element_&, DOM_Element_, void)
bool hasAttribute_ (DOM_Element_, string)
bool hasChildElements_ (DOM_Element_)
DOM_Element_ getDocumentElement_ (DOM_Document_)
string getElementText_ (DOM_Element_)
DOM_Document_ parseXMLBuffer_ (Buffer)
DOM_Document_ parseXMLString_ (string)

Re: DOORS XML support
SystemAdmin - Thu May 06 11:38:43 EDT 2010

When you say "XML data from MS Word", do you mean "docx" XML?

Re: DOORS XML support
GeorgesReti - Fri Dec 03 19:03:52 EST 2010

Mathias Mamsch - Thu Apr 29 04:37:01 EDT 2010

DOORS DXL has integrated perms to read XML (see below). You can use them to parse an XML file and read tags and their attributes. I guess the meaning and the usage of the perms are obvious, they are a simple wrapping of the "MS DOM Document" OLE class. If you want a more complete library to read and write XML you can take a look at the "DXL standard library" on sourceforge. This is an open source project I founded, which is not yet ready to release, but already contains a very functional XML library with a good documentation. Find it here: http://sourceforge.net/projects/dxlstandardlib/.

To answer your second and third question, I guess there are quite some people that already implemented an XML Word import in DXL. However my guess is, that most of these people will not share their code, since they consider it "too valuable" (although they will probably not sell it anyway).

Hope that helps, Regards, Mathias
 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
 

DOM_Document_ getDocumentBuffer_ (DOM_Document_, Buffer&)
string getStringAttribute_ (DOM_Element_, string)
string getElementName_ (DOM_Element_)
string setStringAttribute_ (DOM_Element_, string, string)
void ::do (DOM_Element_&, DOM_Element_, void)
void ::do (DOM_Element_&, DOM_Element_, void)
bool hasAttribute_ (DOM_Element_, string)
bool hasChildElements_ (DOM_Element_)
DOM_Element_ getDocumentElement_ (DOM_Document_)
string getElementText_ (DOM_Element_)
DOM_Document_ parseXMLBuffer_ (Buffer)
DOM_Document_ parseXMLString_ (string)

I see there is a way to loop through DOM_Element_s of a DOM_Element_, but I see no way to loop through attributes of a DOM_Element_. That means I need to know the attributes names to get their values. This is odd as in XML,

> <element>
> <attribute1>value1</attribute1>
> <attribute2>value2</attribute2>
> <attribute3>value3</attribute3>
> </element>

is strictly identical to

> <element attribute1="value1" attribute2="value2" attribute3="value3"/>

I can handle the first for nicely with a loop, even if I do not know the name of the elements, while I need to fetch each attribute individually using their names in the second form.

Any thoughts?

Re: DOORS XML support
Mathias Mamsch - Wed Dec 15 18:53:33 EST 2010

GeorgesReti - Fri Dec 03 19:03:52 EST 2010
I see there is a way to loop through DOM_Element_s of a DOM_Element_, but I see no way to loop through attributes of a DOM_Element_. That means I need to know the attributes names to get their values. This is odd as in XML,

> <element>
> <attribute1>value1</attribute1>
> <attribute2>value2</attribute2>
> <attribute3>value3</attribute3>
> </element>

is strictly identical to

> <element attribute1="value1" attribute2="value2" attribute3="value3"/>

I can handle the first for nicely with a loop, even if I do not know the name of the elements, while I need to fetch each attribute individually using their names in the second form.

Any thoughts?

The builtin perms won't help you with that. The DXL standard library has no support for iterating over the attributes of a node yet either, but it is pretty straight forward to add that.

As a quick fix you can add:
 

XMLNodelist attributes (XMLTag xt) {
    DxlObject x = new; XMLNodelist result = (addr_ x) XMLNodelist; 
    
    OleAutoObj oleNodeList = null
    checkOLE (  oleGet (getOleHandle_ xt, "attributes", oleNodeList)   ) 
    if (null oleNodeList) { raiseError ("DOM ERROR", "selectNodes returned no result."); return null XMLNodelist }
    
    setOleHandle_ (result, oleNodeList) 
    setParentDocument_ (result, getParentDocument xt) 
    setCurrentNode_    (result, null XMLTag) 
    return result
}

 


to the XMLDocument.inc and then the modified example, shows you how to iterate the attributes:

 

 

 

#include <lib/DXLstdlib.inc>
#include <lib/XMLDocument.inc>
 
// appends a person with name and telephone number to the xtPerson tag
XMLTag  appendPerson (XMLTag xtPerson, string sGender, string sName, string sTelephone) {
    XMLTag xt  = appendTag(xtPerson, "Person") 
    setAttribute (xt, "Gender", sGender)
    setText (appendTag (xt, "Name"), sName) 
    setText (appendTag (xt, "Phone"), sTelephone)
    return xt 
}
 
// create the XMLDocument
XMLDocument x = create_XMLDocument() 
 
 
Buffer b = create(); b += "<some CData[]> Stuff\001\007"
XMLTag v = create_CDATASection(x,  b)
 
 
// create a node for our phonebook 
XMLTag xtp = appendTag (x, "Phonebook")
appendChild(xtp, v)
 
// insert some data
appendPerson ( xtp, "male", "Mr. Schmidt", "012-3456" ) 
XMLTag vv = appendPerson ( xtp, "female", "Mrs. Meyer", "056-7890" )
 
XMLNodelist nl = attributes vv 
 
print "Attributes:" (count nl) "\n"
print "Attribute Name:" (getName getItem(nl, 0) ) "\n"
print "Attribute Value:" (getText getItem(nl, 0) ) "\n"
 
 
// print the generated XML
print getXML x
 
// make sure that the DXLDocument is always cleaned up after usage
delete_XMLDocument x



Hope this helps, regards, Mathias



 

 

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

Re: DOORS XML support
PatrickGuay - Mon Aug 15 15:28:40 EDT 2011

Hi, I am struggling with getElementText_() when there are multiple text for a given XML tag.
<para>
If the temperature is below
<quantity>
<qtygrp>
<qtyvalue qtyuom = "degC">-15</qtyvalue>
</qtygrp>
</quantity>

(
<quantity>
<qtygrp>
<qtyvalue qtyuom = "degF">5.00</qtyvalue>
</qtygrp>
</quantity>

), do the cold-weather maintenance procedure
</para>

Using getElementText_() only returns me the following text "If the temperature is below". Can anyone provide information on how to obtain the other text in the <para> tag shown above? Thanks in advance