View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0025683 | Community | OCCT:Application Framework | public | 2015-01-06 05:52 | 2023-08-01 15:09 |
Reporter | Vico Liang | Assigned To | vro | ||
Priority | low | Severity | minor | ||
Status | assigned | Resolution | open | ||
Target Version | Unscheduled | ||||
Summary | 0025683: Application Framework - No entrance to construct a LDOMBasicString from TCollection_ExtendedString | ||||
Description | To support unicode in XML driver, TCollection_ExtendedString is a way provided by OCCT. There is a class XmlObjMgt to manage the TCollection_ExtendedString storage for XmlObjMgt_Element text value. But it can't store TCollection_ExtendedString in attribute. //! Add attribute <theElement extstring="theString" ...> Standard_EXPORT static Standard_Boolean SetExtendedString (XmlObjMgt_Element& theElement, const TCollection_ExtendedString& theString) ; //! Get attribute <theElement extstring="theString" ...> Standard_EXPORT static Standard_Boolean GetExtendedString (const XmlObjMgt_Element& theElement, TCollection_ExtendedString& theString) ; The best way to solve this issue is to provide a method to construct a LDOMBasicString from TCollection_ExtendedString. This method can be in class XmlObjMgt. | ||||
Tags | No tags attached. | ||||
Test case number | |||||
related to | 0025681 | closed | bugmaster | Community | Application Framework - Unicode data storage in XML or binary format |
related to | 0025682 | closed | bugmaster | Community | Application Framework - TObj_Model::GetModelName() should store in document in unicode mode instead of ascii mode |
child of | 0022484 | closed | bugmaster | Open CASCADE | UNICODE characters support. |
|
Two methods like these might work: XmlObjMgt_DOMString XmlObjMgt::ToDOMString(const TCollection_ExtendedString& theString) { TCollection_AsciiString anAString; if (theString.IsAscii()) { anAString = TCollection_AsciiString(theString, '?'); return XmlObjMgt_DOMString(anAString.ToCString()); } else { const Standard_Integer aLen = theString.Length(); char * buf0 = new char[4 * (aLen + 1) + 3]; Sprintf(&buf0[0], "##%04x", 0xfeff); // set UNICODE header char * buf = &buf0[6]; SprintfExtStr(buf, theString); XmlObjMgt_DOMString aDOMString(buf0); delete[] buf0; return aDOMString; } } XmlObjMgt_DOMString XmlObjMgt::ToDOMString(const TCollection_AsciiString& theString) { return XmlObjMgt_DOMString(theString.ToCString()); } |
|
Hello Vico. I'm not sure I understand well your proposal... sorry. The methods you declare above exist in XmlObjMgt.cxx the lines 108..152. Do you mean renaming of the methods? What is the added-value? |
|
Dear vro, Sorry for that my description is not clear. My proposal doesn't mean method renaming but provide a mean to create XmlObjMgt_DOMString from TCollection_ExtendedString. The background is that i want to save TCollection_ExtendedString data in xml file, and the data might be store in XML attribute, text, and comment nodes. But all these nodes just accept XmlObjMgt_DOMString as input rather than TCollection_ExtendedString. To construct XmlObjMgt_DOMString from TCollection_ExtendedString, there are two means: The first is to add a constructor XmlObjMgt_DOMString(const TCollection_ExtendedString& theString); The second is to add a utility method : XmlObjMgt_DOMString XmlObjMgt::ToDOMString(const TCollection_ExtendedString& theString); Is it clear? |
|
Hello Vico, many thanks, now it is clearer. Would it be possible to use a TDataStd_Comment or TDataStd_Name attributes to store a TCollection_ExtendedString object in XML document? Or do you consider an opportunity to store a UNICODE string without OCAF? In general, I don't see any obstacles to implement these additional methods (one of them). Would you do it? |
|
Dear vro, Actually i'm using OCAF, and i find a bug in XmlTObjDrivers_ReferenceDriver which will cause issue if the model name is unicode. Please see my fix in last two lines, i added my own utility method XmlObjMgt::ToDOMString to correct the UNICODE issue, the implementation is like my previous post. I do hope that OCCT can have an entrance to construct XmlObjMgt_DOMString from TCollection_ExtendedString directly. I may want to extend OCAF built-in attributes to support application domain UNICODE. void XmlTObjDrivers_ReferenceDriver::Paste (const Handle(TDF_Attribute)& Source, XmlObjMgt_Persistent& Target, XmlObjMgt_SRelocationTable& /*RelocTable*/) const { Handle(TObj_TReference) aSource = Handle(TObj_TReference)::DownCast (Source); Handle(TObj_Object) aLObject = aSource->Get(); if (aLObject.IsNull()) return; // referred entry TCollection_AsciiString entry; TDF_Label aLabel = aLObject->GetLabel(); TDF_Tool::Entry( aLabel, entry ); Target.Element().setAttribute(::ReferredEntry(), entry.ToCString()); // master entry entry.Clear(); TDF_Label aMasterLabel = aSource->GetMasterLabel(); TDF_Tool::Entry( aMasterLabel, entry ); Target.Element().setAttribute(::MasterEntry(), entry.ToCString()); // is reference to other document if (aLabel.Root() == aMasterLabel.Root()) return; Handle(TObj_Model) aModel = Handle(TObj_Model)::DownCast( aLObject->GetModel() ); XmlObjMgt_DOMString aModelName = XmlObjMgt::ToDOMString(aModel->GetModelName()->String()); Target.Element().setAttribute(::ReferredModelEntry(), aModelName); } |
|
Current implementation of Unicode support (converting to hex representation and back) in LDOM is ugly and unsymmetric: such strings are encoded by method XmlObjMgt::SetExtendedString() accepting XmlObjMgt_Element, but decoder is implemented as operator TCollection_ExtendedString() of LDOMBasicString()... The overall logic of the code should be fixed first, so that conversions back and forth are implemented on the same level. |
|
It should be noted that the problem with saving and restoring cross-model references in XmlTObjDrivers_ReferenceDriver due to its inability to handle correctly Unicode in the model name does not seem blocking for anything: the name of the model in TObj is not intended to be visible to the end user, it is rather an internal ID of the model in the hierarchy, so it can be (and better be) defined using only ASCII characters. |
Date Modified | Username | Field | Change |
---|---|---|---|
2015-01-06 05:52 | Vico Liang | New Issue | |
2015-01-06 05:52 | Vico Liang | Assigned To | => szy |
2015-01-06 06:05 | Vico Liang | Note Added: 0035918 | |
2015-03-05 11:23 |
|
Priority | normal => low |
2015-03-05 11:23 |
|
Target Version | 6.9.0 => 6.7.1 |
2015-03-05 11:42 |
|
Target Version | 6.7.1 => 7.1.0 |
2015-12-30 16:04 |
|
Assigned To | szy => vro |
2015-12-30 16:04 |
|
Status | new => assigned |
2016-02-09 11:47 | vro | Assigned To | vro => Vico Liang |
2016-02-09 11:51 | vro | Note Added: 0050515 | |
2016-02-11 14:18 | Vico Liang | Note Added: 0050632 | |
2016-02-11 14:19 | Vico Liang | Assigned To | Vico Liang => vro |
2016-02-11 14:27 | vro | Note Added: 0050633 | |
2016-02-11 14:27 | vro | Assigned To | vro => Vico Liang |
2016-02-11 15:00 | Vico Liang | Note Added: 0050641 | |
2016-02-11 15:02 | Vico Liang | Assigned To | Vico Liang => vro |
2016-11-03 17:13 |
|
Target Version | 7.1.0 => 7.2.0 |
2017-07-27 09:43 |
|
Target Version | 7.2.0 => 7.4.0 |
2019-07-10 09:01 |
|
Target Version | 7.4.0 => 7.5.0 |
2020-09-11 15:32 |
|
Target Version | 7.5.0 => 7.6.0 |
2020-10-14 11:43 | kgv | Relationship added | related to 0025681 |
2020-10-14 11:47 | kgv | Summary | No entrance to construct a LDOMBasicString from TCollection_ExtendedString. => Application Framework - No entrance to construct a LDOMBasicString from TCollection_ExtendedString |
2020-10-14 11:47 | kgv | Relationship added | child of 0022484 |
2020-10-25 21:09 |
|
Relationship added | related to 0025682 |
2020-10-28 09:09 |
|
Note Added: 0096326 | |
2020-10-29 09:02 |
|
Note Added: 0096356 | |
2021-11-01 18:14 |
|
Target Version | 7.6.0 => 7.7.0 |
2022-10-24 10:39 |
|
Target Version | 7.7.0 => 7.8.0 |
2023-08-01 15:09 | dpasukhi | Target Version | 7.8.0 => Unscheduled |