General XMetaL Discussion
XMetaL Community Forum › General XMetaL Discussion › Retrieving Entity Content
-
scotth August 11, 2011 at 2:47 am
Retrieving Entity Content
August 11, 2011 at 2:47 amParticipants 3Replies 4Last Activity 11 years, 5 months agoUsing 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.
Derek Read August 11, 2011 at 8:04 pm
Reply to: Retrieving Entity Content
August 11, 2011 at 8:04 pmThere is an API for this:
ActiveDocument.doctype.entitiesFrom 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.
scotth August 11, 2011 at 8:16 pm
Reply to: Retrieving Entity Content
August 11, 2011 at 8:16 pmActiveDocument.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.
Derek Read August 12, 2011 at 12:03 am
Reply to: Retrieving Entity Content
August 12, 2011 at 12:03 amYou are correct.
[quote=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.
Derek Read August 12, 2011 at 12:12 am
Reply to: Retrieving Entity Content
August 12, 2011 at 12:12 amYou 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.
-
AuthorPosts
- You must be logged in to reply to this topic.