General XMetaL Discussion

XMetaL Community Forum General XMetaL Discussion Retrieving Entity Content

  • scotth

    Retrieving Entity Content

    Participants 3
    Replies 4
    Last Activity 11 years, 1 month ago

    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.

    Reply

    Derek Read

    Reply to: Retrieving Entity Content

    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.

    Reply

    scotth

    Reply to: Retrieving Entity Content

    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.

    Reply

    Derek Read

    Reply to: Retrieving Entity Content

    You 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.

    Reply

    Derek Read

    Reply to: Retrieving Entity Content

    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.

    Reply

  • You must be logged in to reply to this topic.

Lost Your Password?

Products
Downloads
Support