1. Does DOORS support XML? |
Re: DOORS XML support
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/.
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 |
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/.
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) > <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 GeorgesReti - Fri Dec 03 19:03:52 EST 2010
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.
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
}
#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
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: DOORS XML support <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 |