General XMetaL Discussion
scotth November 17, 2011 at 6:55 pm
Insert Entity With XML MarkupNovember 17, 2011 at 6:55 pmParticipants 6Replies 7Last Activity 11 years, 2 months ago
Does XMetaL support entities that include xml markup? If so, how can this be achieved? For example, let's say that I try to setup an entity with a definition like this:
test. I then insert an entity reference in XMetaL where a para would normally go. When I do this, I get an error message in my validation errors list saying “Text not allowed here.”.Derek Read November 17, 2011 at 8:05 pm
Reply to: Insert Entity With XML MarkupNovember 17, 2011 at 8:05 pm
Can you let me know what your goal is?
Perhaps you really need to reference an external entity.scotth November 17, 2011 at 8:39 pm
Reply to: Insert Entity With XML MarkupNovember 17, 2011 at 8:39 pm
The goal is to be able to re-use a complex tag structure across many documents. In this case, it is a warning tag structure with standard warning text.Derek Read November 17, 2011 at 10:04 pm
Reply to: Insert Entity With XML MarkupNovember 17, 2011 at 10:04 pm
Right. Please have a look at external entities then. Basically this means putting your markup into a file all on its own, then reference the file using an external entity reference. The Tools menu has an item for defining this type of entity (ie: Insert > External Entity) and once it has been defined you can insert a reference to it using Insert > Entity Reference.
You will want to check that your publishing or transformation system supports external entities. More information here if you need to reference the XML Recommendation: http://www.w3.org/TR/REC-xml/#sec-external-entscotth November 21, 2011 at 3:18 pm
Reply to: Insert Entity With XML MarkupNovember 21, 2011 at 3:18 pm
Will I have to relax the restrictions of my schema to allow for text in locations where I want to be able to insert these external entity references? When I insert the reference currently, I get a validation error stating “Text not allowed here.” My entity contains “
testing“, and I am inserting the reference in a location where a para tag is allowed by the schema.Derek Read November 21, 2011 at 5:57 pm
Reply to: Insert Entity With XML MarkupNovember 21, 2011 at 5:57 pm
That should not be necessary. Perhaps you can submit some files to XMetaL Support so they can have look and see.Derek Read November 21, 2011 at 6:31 pm
Reply to: Insert Entity With XML MarkupNovember 21, 2011 at 6:31 pm
I see now. When you say “schema” you mean an actual W3C Schema (not schema in the general sense which includes DTD).
I can reproduce your issue with the Journalist sample, provided I use the journalist.xsd (W3C Schema) and not journalist.dtd.
Support for entities when used with DTDs is clearly defined by the W3C recommendations and the software supports that. The W3C Schema Primer contains a very short addendum here that discusses a very simple entity use case: http://www.w3.org/TR/xmlschema-0/#usingEntities
It does not clearly define how entities should be used. I don't believe we've done any real testing or development in this area (beyond what I've noted below). I've seen various attempts at implementing support for this type of thing in different software, but they seem to disagree with each other (which is understandable given the lack of clearly defined rules).
What is supported in XMetaL is the following type of XML document:
It seems that this is the one case where most XML parsers agree. In the file “bunchofentities.dtd” you may declare entities and they can be used in the document (as with any other DTD) while the Schema is used for validation. However, the entities will be limited to character and text entities. This doesn't give you anything more than what is also supported in the internal subset. i.e.: in both cases you cannot include markup. That will only work when a DTD is being used.
It is possible that we might attempted to support something like this in the future but I would probably argue for clear rules from the W3c before we attempted anything.
To answer your question, if you were to relax your Schema to allow text at these positions that would not help, or at the very best I think it would confuse things further.Derek Read November 23, 2011 at 2:18 am
Reply to: Insert Entity With XML MarkupNovember 23, 2011 at 2:18 am
Another thought… have you considered XInclude? I think that would be a pretty versatile solution for your needs, provided other tools you use support it as well (probably most importantly: anything that does your transformations for you, though we include an API that will write out a combined document with all XIncludes merged into the document they are referenced from).
This would require you to modify your Schema (to define the XInclude elements according to the XInclude spec) plus you would need to do some scripting to enable the feature and expose those actions you want your users to be able to perform.
If you wish to see this in action an example is included with a demo we are shipping for DocBook.
To see this demo:
1. Open the sample here: Help > Samples > Anatomy and Physiology (DocBook)
2. Locate an
(we have styled them in yellow) right click on it and select one of the three options we have exposed on the context menu ('Show/Hide XML Inclusion' and 'Open XML Inclusion Target').
The code for this demo is located here:
C:Program FilesXMetaL 6.0AuthorRulesDocBook5.0xidocbookxi.mcr
C:Program FilesXMetaL 6.0AuthorRulesDocBook5.0xidocbookxi.js
Note that although this demo uses the DocBook DTDs the feature itself (the APIs) should function for any DTD or Schema provided it supports the required elements (see here: http://www.w3.org/TR/xinclude/#syntax).
There are quite a few more APIs available than those exposed in the demo. Check the most recent Programmer's Guide and search for “xinclude” to find (probably all) information on them.
We don't attempt to provide a default GUI for working with XInclude for various reasons, but mostly because we felt that to function best this feature needs to be tailored to your authoring environment, workflow, business rules, exact user needs and possibly even tied into 3rd party systems. Implementing something out of the box might just get in the way of anyone that really needs it forcing them to disable some things and override or change others. So, we leave it up to the developer (for either XMetaL Author Essential, or Enterprise, or even XMAX customizations) to decide which XInclude functionality they wish to enable, how to expose it to the end user and exactly how and when it will function. This gives you full control over which to expose, how you want to expose them (via shortcut, menus, toolbars, context menu, or dialog, or perhaps even via the Resource Manager) and build a GUI that matches your user's exact needs.
- You must be logged in to reply to this topic.