Changing Default Attribute Values

Oxygen general issues.
rb_online
Posts: 2
Joined: Wed Dec 14, 2011 8:53 pm

Changing Default Attribute Values

Post by rb_online »

I'm currently running oXygen Author (version 12.2) and I was wondering if there is a way to change the default attribute values. Specifically, I'm looking to change the placement attribute (of the image element) from inline to break. Any help would be much appreciated.

Thank you,

Rob
adrian
Posts: 2855
Joined: Tue May 17, 2005 4:01 pm

Re: Changing Default Attribute Values

Post by adrian »

Hello,

What type of document are you editing(DocBook, DITA, etc)?
The default attributes are specified in a schema or DTD, so a solution would be to customize the schema/DTD of that document type and adjust the default attribute values.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
rb_online
Posts: 2
Joined: Wed Dec 14, 2011 8:53 pm

Re: Changing Default Attribute Values

Post by rb_online »

We are editing DITA documents. Does anyone know the name and location of the file to modify?
mihaela
Posts: 490
Joined: Wed May 20, 2009 2:40 pm

Re: Changing Default Attribute Values

Post by mihaela »

Hi Rob,

oXygen uses DITA Open Toolkit to process DITA documents. The DTDs and XSL stylesheets from the DITA Open Toolkit are packed in the oXygen distribution, and you can found them inside the [Oxygen-install-folder]/frameworks/dita/DITA-OT folder.

You can change the default value of the placement attribute in the commonElements.mod document (from DITA-OT/dtd/base/dtd folder) but we think that is better to make changes on the publishing side (DITA_OT XSLT stylesheets) than on the attribute declaration side.

Best regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
craig_sandvik
Posts: 5
Joined: Thu Dec 08, 2011 10:41 pm

Re: Changing Default Attribute Values

Post by craig_sandvik »

If you change the DTD default for <image> @placement, you may have problems down the road if you need to mix your content with content from an implementation that follows the standard.

I think it's better to modify the image insertion code to set @placement.

I was able to get @placement set to "break" for new image insertion with a custom document filter using the code below. It might be nice if the image insertion code in Oxygen set @placement based on the intrinsic size of the image being inserted. (In our environment, images are inserted by a CMS action, so we need the custom code regardless.)

Code: Select all

protected class MyDITAAuthorListener extends AuthorListenerAdapter {
/**
* Filter inserted <image> to set @placement="break" if it is not
* explicitly set.
* Note this does affect paste of a single <image>: if @placement is
* not explicitly set in the pasted element, it will be set to "break".
*/
@Override
public void beforeContentInsert(DocumentContentInsertedEvent e) {
AuthorNode node = null;
if (e.getType() == DocumentContentChangedEvent.INSERT_NODE_EVENT) {
node = e.getInsertedNode();
} else if (e.getType() == DocumentContentChangedEvent.INSERT_FRAGMENT_EVENT) {
AuthorDocumentFragment frag = e.getInsertedFragment();
List<AuthorNode> nodeList = frag.getContentNodes();
if (nodeList != null && nodeList.size() == 1) {
node = nodeList.get(0);
}
}
if (node != null && (node.getType() == AuthorNode.NODE_TYPE_ELEMENT)) {
AuthorElement element = (AuthorElement) node;
if (element.getName().equals("image")) {
AttrValue placementAttr = element.getAttribute("placement");
if (placementAttr == null || !placementAttr.isSpecified()) {
element.setAttribute("placement", new AttrValue("break"));
}
}
}
super.beforeContentInsert(e);
}
}
Post Reply