Extending props with Relax NG

34 views
Skip to first unread message

Jason Davis

unread,
Aug 26, 2020, 6:48:40 PM8/26/20
to DITA-OT Users
Hi all,

I'm currently trying to extend the props attribute to create a custom filtering attribute. The attribute is now valid/doesn't break builds when used. The problem is it's still not working for profiling. I'm wondering what I'm missing. I've added the following to my module:

<define name="form-factorAtt-d-attribute">
    <optional>
      <attribute name="form-factor">
        <a:documentation>attribute documentation...blah, blah, blah...</a:documentation>
      </attribute>
    </optional>   
  </define>
  <define name="props-attribute-extensions" combine="interleave">
    <ref name="form-factorAtt-d-attribute"/>
  </define>

Any pointers would be appreciated!

Thanks,
Jason

Chris Papademetrious

unread,
Aug 26, 2020, 7:50:06 PM8/26/20
to DITA-OT Users
Hi Jason,

You could try using my utility to create your RelaxNG grammar for you:


You could compare its results to your files to see if it did something different. Start with this as the definition file:

<plugin directory="./com.my.att" uri_prefix="com:my:att">
 <attributedomain filename="form-factor.rng" domain="formfactorAtt">
  <specialize attribute="form-factor" from="props"/>
 </attributedomain>

 <topicshell filename="myTopicShell.rng">
  <title>My Topic</title>
  <root_element>topic</root_element>
  <include_domains>topic formfactorAtt</include_domains>
 </topicshell>
</plugin>

 - Chris

Jason Davis

unread,
Aug 27, 2020, 2:26:08 PM8/27/20
to DITA-OT Users
Hi Chris,

Thanks so much for sharing this with me. I ran your utility and it seemed to fail with the following

Creating 'form-factor.rng' (attributedomain)...

 Creating 'myTopicShell.rng' (topicshell)...

Can't find domains 'formfactorAtt' at /Users/jasondavis/Sandbox/dita-utils/DITA-plugin-utilities/bin/make_dita_grammar.pl line 296.

I wasn't quite sure how to address this. However, it did appear to successfully create the attribute module, which doesn't appear to be all that different than what I put together initially. Any ideas?

Thanks,
Jason

Jason Davis

unread,
Aug 27, 2020, 7:06:23 PM8/27/20
to DITA-OT Users
I see what I did wrong. I had forgotten to update my document shell with the reference to the new domain. It now behaves like I expect in terms of profiling. 

Thanks again!
Jason

Chris Papademetrious

unread,
Aug 29, 2020, 9:03:52 AM8/29/20
to DITA-OT Users
Hi Jason,

Sorry, I should have tested that without posting. My code assumes the DITA-OT convention that the attribute domain name matches the attribute name itself:

<plugin directory="./com.my.att" uri_prefix="com:my:att">
 <attributedomain filename="form-factor.rng" domain="form-factor">

  <specialize attribute="form-factor" from="props"/>
 </attributedomain>

 <topicshell filename="myTopicShell.rng">
  <title>My Topic</title>
  <root_element>topic</root_element>
  <include_domains>topic form-factor hi-d pr-d</include_domains>
 </topicshell>
</plugin>

I will file an issue to handle this and/or add a check if they differ.

You can add additional domains to your docshell, as shown in red above. Once it's created, you can verify the content models contain your new attribute as follows:

./bin/content_model.pl --attributes all com.my.att/rng/myTopicShell.rng

 - Chris
Reply all
Reply to author
Forward
0 new messages