xml - Is it possible to dynamically specify the location of an external entities file? -
i have generic xml snippets need use different entities files depending on context (project) using in. don't want copy/paste them on place, duplicating code.
xml entities don't propagate xincluded elements , it's not possible dynamically specify location either (which, well, wouldn't work same reason entities don't propagate).
what feasible way feed different entity files generic xml snippet, depending on context, works all/most xml tools?
depends on processing environment. many xml parsers allow specify entityresolver or xmlresolver callback process , resolve external entity references. layered on top of this, find parsers or other utilities support oasis catalogs, allow define indirections entity references in xml catalog file.
personally, prefer not use entity references kind of application, use custom markup instead. (some people prefer xlink/xinclude, prefer roll own.) it's easy process links/transclusions using xslt. particular benefit it's hard transform xml while leaving entity references intact, becomes easy leave links intact if use logical (element-level) markup.
Comments
Post a Comment