Pages: 1
Print
Author Topic: Retrieving Entity Content  (Read 292 times)
scotth
Member

Posts: 35


« on: August 10, 2011, 08:47:42 PM »

Using XMAX 6.0, is there anyway through the API to retrieve entity content? I am working on building up an insert entity reference dialog, much like the one provided in XMetaL, and wanted to show the entity names and content. Worst case, I will parse the document separately on my own and retrieve the content.
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 1548



WWW
« Reply #1 on: August 11, 2011, 02:04:49 PM »

There is an API for this:
ActiveDocument.doctype.entities

From the Programmer's Guide: "Returns a DOMNamedNodeMap of DOMEntity objects representing the general entities, both external and internal, declared in the DTD. Duplicates are discarded."

DOMNamedNodeMap and its property and various methods are what you would end up using.
Logged
scotth
Member

Posts: 35


« Reply #2 on: August 11, 2011, 02:16:45 PM »

ActiveDocument.doctype.entities works great for names and IDs. Unfortunately, it does not seem to provide a way to display the entity's value. Take a look at the right-hand column in XMetaL's Insert Entity Reference dialog to get an idea of what I am talking about.
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 1548



WWW
« Reply #3 on: August 11, 2011, 06:03:43 PM »

You are correct.

Quote from: Programmer's Guide 'nodeValue'
The DOM specification details which types of nodes have values, and where the values come from:
 - DOMAttr: the attribute value
 - DOMText: the text
 - DOMCDATASection: content of the section
 - DOMProcessingInstruction: everything in the PI except the target.
 - DOMComment: content of the comment.
 - DOMCharacterReference: the decimal number corresponding to the character (extension to DOM)
 - All other nodes: null.

Entities fall into the last category, so this API will return null.
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 1548



WWW
« Reply #4 on: August 11, 2011, 06:12:46 PM »

You might use a strategy whereby all your entities are contained within a file separate from the main DTD and use a parameter entity in the DTD to reference it. That might make extracting their values slightly easier.
Logged
Pages: 1
Print
Jump to: