Pages: 1
Print
Author Topic: Reusable Component Question: Why the stragglers?  (Read 2031 times)
nouspoetikos
Member

Posts: 2


« on: October 24, 2014, 09:01:58 AM »

Hello,

I'm wondering if you could help me with a reusable component question in XMetaL7 Author on Windows.

I have this reusable component file created via XMetaL's 'Create Reusable Component' menu:

<?xml version="1.0"?>
<!DOCTYPE ditacomponent PUBLIC "-//XMETAL//DTD DITA Component//EN" "ditacomponent.dtd">
<ditacomponent id="ditacomponent_ADF8DA06C0144A8781AF80EC7367E5D3">
   <description>test of re-usable component</description>
   <compbody>
      <reusable-content>
         <conbody id="conbody_B45428C408E04DBA87ECE5041CFAB560">
            <p id="thisIdIsAlsoValidated">This is a conbody that I wanted to turn into a reusable component</p>
         </conbody>
    </reusable-content>
   </compbody>
</ditacomponent>


And the file below which includes the reusable component. If you look at the conbody element, XMetaL has automatically inserted a call to the reusable component file above. 

<?xml version="1.0"?>
<!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="test">
  <title>Testing Re-usable Component</title>
  <shortdesc>Some text</shortdesc>
  <conbody conref="file:///E:/users/ReusableComponentOddness/testOfRe-usableComponent.xml#ditacomponent_ADF8DA06C0144A8781AF80EC7367E5D3/conbody_B45428C408E04DBA87ECE5041CFAB560">
        <p><?xm-replace_text Paragraph?></p>
   </conbody>
</concept>


When XMetaL inserts the reference to the conref, it adds tags (without their ids or contents). In this case, the conbody has lost the id and contains a p which has equally lost its id and contents.

When one returns to edit the file after XMetaL's initial insertion, one can remove the empty <p> under <conbody> without any problems. The reusable component continues to work....so clearly, the empty <p> (or empty first children in the case of reusable components inserted generally) is not absolutely necessary for the resolution of the reusable component during build time.

I have validation checks do not play well with the way XMetaL automagically inserts the re-usable components and, while it's possible to work around the reusable component context, it seems odd to me that I need to loosen the rule because the editor itself is leaving empty <p>'s behind. I have additional checks (on id's for example) that equally hit problems with re-usable components.
 
I could ask the writers to go back in after the reusable component has been added and remove the extra tags and/or re-add the ids but that seems painful.

Is there any way to alter the default insertion behavior so that:
  • Ids on the element referenced are retained?
    Child elements are not emptied and copied over?
 

Thanks in advance for your help,
Heather

     
Logged
tonys
JustSystems Partner
Member

Posts: 80


« Reply #1 on: October 24, 2014, 03:49:18 PM »

Hi,

This is a consequence of the way conrefs work. When you have an element like:

<p conref="XXX">This text is always ignored</p>

it tells a DITA processor to ignore whatever is inside the element, and instead to use the contents of the <p> element identified by "XXX". The situation with attributes is a bit more complex; you can see a description in section 2.1.3.5 of the DITA 1.2 standard. One thing this states is that the id attribute is never copied from the referenced element. There's a good reason for this: since it may be referenced many times it could lead to duplicate identifiers. For the same reason, id attributes should be avoided within reusable content.

The content that XMetaL is adding is purely for the convenience of the user, so something appears where the replacement will occur - it has nothing to do with the content that is actually referenced.

I'm not sure what sort of validation you are doing, but to be correct it should either ignore the content within the conref element, or replace it with the referenced content.
Logged
Pages: 1
Print
Jump to: