Copy link to clipboard
Copied
To get label for page item I am using below chunk of code. But same code is not working for inline xml tag.
PMString TestUtility::GetScriptLabel(UIDRef pageItemRef, PMString key)
{
PMString labelValue;
labelValue.SetTranslatable(false);
InterfacePtr<IScript> iscript(pageItemRef , IScript::kDefaultIID );
if(iscript)
{
if(key == "default")
{
labelValue = iscript->GetTag();
}
else
{
labelValue = iscript->GetTag(key);
}
}
return labelValue;
}
Please suggest something.
The following function should do the job:
...PMString GetXMLTagLabel(IDocument* doc, WideString& tagName) {
PMString label("");
if(!doc)
return label;
InterfacePtr<IXMLTagList> tagList(doc->GetDocWorkSpace(), UseDefaultIID());
if(tagList)
{
UID tagUID = tagList->GetTag(tagName);
UIDRef tagRef = UIDRef(::GetDataBase(doc), tagUID);
InterfacePtr<IScript> script(tagRef, UseDefaultIID());
if(script) {
label.Append(script->GetTag());
Copy link to clipboard
Copied
Each XML tag (IXMLTag) is an instance of kXMLTagBoss.
If you pass UIDRef of the XML tag then you should be able to get the label using IScript::GetTag.
Ensure that you are passing correct UIDRef.
The following is how you can get UIDRef of an XML Tag using the tag name.
InterfacePtr<IXMLTagList> tagList(document, UseDefaultIID());
UID tagUID = tagList->GetTag(tagName);
UIDRef tagRef = UIDRef(document.GetDataBase(),tagUID);
Copy link to clipboard
Copied
The following function should do the job:
PMString GetXMLTagLabel(IDocument* doc, WideString& tagName) {
PMString label("");
if(!doc)
return label;
InterfacePtr<IXMLTagList> tagList(doc->GetDocWorkSpace(), UseDefaultIID());
if(tagList)
{
UID tagUID = tagList->GetTag(tagName);
UIDRef tagRef = UIDRef(::GetDataBase(doc), tagUID);
InterfacePtr<IScript> script(tagRef, UseDefaultIID());
if(script) {
label.Append(script->GetTag());
}
}
return label;
}
Copy link to clipboard
Copied
Thanks Vinothr your solution worked
. I was using ::GetUIDRef() to get uid reference of xml tag but it wasn't working. Thanks for the reference code now i am able to get label for my tag
.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more