CSS styling for specialization

<oXygen/> general issues.
anderszvensson
Posts: 71
Joined: Wed Jul 14, 2010 11:38 am

CSS styling for specialization

Post by anderszvensson » Tue Sep 14, 2010 3:42 pm

Hi,

I read on your site that if you have a specialization (for DITA), the default CSS should be able to handle it because it looks at the class attributes.

I'm going to create a specialization, but just wanted to make sure this would work before I do it. So I tried the specialization made in the Lone DITA tutorial (if you know it). So that's a specialization of the task topic for recipes. It has the associations for the class attributes at the end of the mod file, like so:

Code: Select all

<!ATTLIST recipe        %global-atts;  class  CDATA "- topic/topic task/task recipe/recipe "        >
<!ATTLIST recipebody %global-atts; class CDATA "- topic/body task/taskbody recipe/recipebody" >
<!ATTLIST instructions %global-atts; class CDATA "- topic/ol task/steps recipe/ingredients" >
<!ATTLIST instruction %global-atts; class CDATA "- topic/li task/step recipe/instruction " >
<!ATTLIST ingredientlist %global-atts; class CDATA "- topic/ul recipe/ingredients" >
<!ATTLIST ingredient %global-atts; class CDATA "- topic/li recipe/ingredient " >
<!ATTLIST description %global-atts; class CDATA "- topic/section task/context recipe/description" >
<!ATTLIST serving %global-atts; class CDATA "- topic/section task/postreq recipe/serving" >
I then tried to associate the task CSS (in the Dita folder of Oxygen) with an XML file:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE recipe SYSTEM "file:/C:/Users/Anders/Documents/AndersCom/Dita/tutorial/dtd/recipe.dtd">
<?xml-stylesheet type="text/css" href="../../../../../../../Program%20Files/Oxygen%20XML%20Editor%2011/frameworks/dita/css/task.css"?>
<recipe id="untitled" xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/">
<title></title>
<prolog/>
<recipebody/>
</recipe>
While it is possible to write in author view with this, the styling isn't really there. What I get is just a bunch of tag symbols, one after another in a long row (no blocks or anything).

Am I doing something wrong?

Also, eventually I would of course want to have a template for this new specialization, and I wouldn't want to have to set the CSS manually each time to edit a new file. So how can I set the CSS permanently for a specific specialization and its template?

Regards,

Anders

anderszvensson
Posts: 71
Joined: Wed Jul 14, 2010 11:38 am

Re: CSS styling for specialization

Post by anderszvensson » Tue Sep 14, 2010 4:03 pm

Sorry, my mistake. Apparently I was using the wrong version of the CSS. When I used the ones under css_classed it worked fine. The second part of the question still stands, though, how to get the association set once and for all for a specialization and template?

Also, I was wondering about the syntax of the css in the css_classed files. Is the tilde and so on standard css syntax? I don't recognize if from what I have done in css before:

Code: Select all

*[class~="task/task"] > *[class~="topic/title"]
Regards,

Anders

Radu
Posts: 6979
Joined: Fri Jul 09, 2004 5:18 pm

Re: CSS styling for specialization

Post by Radu » Tue Sep 14, 2010 4:25 pm

Hi Anders,

Right, only the DITA CSS's in OXYGEN_INSTALL_DIR/frameworks/dita/css_classed which are the default used CSS's can be used with any DITA specialization.
The constructs *[class~="task/task"] are valid CSS selectors and they mean any element with the attribute class whose value contains task/task.
See this link:
http://www.w3.org/TR/CSS2/selector.html ... -selectors

Here are some more answers:
1) Getting the topic files which use your specialization recognized in Oxygen as having DITA document type (this means you will no longer need to associate the CSS hard-coded in the topics):
1.1) In the Oxygen Preferences->Document Type Association check the checkbox Enable DTD/XML Schema processing....
1.2) The best thing to do is not to reference the specialization DTD's location hardcoded in the topics like <!DOCTYPE recipe SYSTEM "file:/C:/Users/Anders/Documents/AndersCom/Dita/tutorial/dtd/recipe.dtd"> but to use a public ID like:
<!DOCTYPE recipe PUBLIC RECIPE SYSTEM "recipe.dtd">
Then have this PUBLIC ID mapped in an XML catalog like:
<public publicId="-//OASIS//ELEMENTS DITA Topic//EN" uri="file:/C:/Users/Anders/Documents/AndersCom/Dita/tutorial/dtd/recipe.dtd"></public>
In this case the best thing to do is to modify the OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT/catalog-dita.xml catalog file and add a new mapping there as this catalog is looked at both by Oxygen and the DITA Open Toolkit which will also need to resolve the PUBLIC ID when the topic gets transformed.
You can find more details here:
http://www.xiruss.org/tutorials/dita-specialization/

2) Setting a new file template:
Just create a file on disk with the content you want.
Then, Oxygen looks for new file templates in 3 places:
1.1) The OXYGEN_INSTALL_DIR/templates directory.
2.2) In any directory specified in the Oxygen Preferences->Editor / Templates / Document Templates page.
2.3) If you edit the DITA document type in the Oxygen Preferences->Document Type Association you can see that there is a tab called Templates which contributes additional template directories to Oxygen.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

anderszvensson
Posts: 71
Joined: Wed Jul 14, 2010 11:38 am

Re: CSS styling for specialization

Post by anderszvensson » Tue Sep 14, 2010 5:50 pm

Ok, thanks. Yes, this was only a quick test, so I am going to use the dtd mapping through the catalog file in the finished specialization.

But I have a follow-up question regarding the css styling. As I said it worked better when I used the css_classed task.css. But apparently not quite perfectly anyway, because when I tried out some other elements (not specialized in the specialization dtd, but kept as the original in the inherited parent type), like table or fig I had problems. First of all, the table and fig icons for inserting these are no longer available in the toolbar, as they are with the regular task templates.

Secondly, if I insert a table through regular element insertion (enter key and code completion), I again get the elements simply lined up in a long row. Why is that? And can I get access to the icons for inserting tables through dialogs just as in the unspecialized type?

Regards,

Anders

anderszvensson
Posts: 71
Joined: Wed Jul 14, 2010 11:38 am

Re: CSS styling for specialization

Post by anderszvensson » Tue Sep 14, 2010 10:41 pm

Never mind, it seems that if I did it the way you described, instead of hard-coding the css, the tables started to work too.

Thanks!

Radu
Posts: 6979
Joined: Fri Jul 09, 2004 5:18 pm

Re: CSS styling for specialization

Post by Radu » Wed Sep 15, 2010 8:11 am

Hi,

Yes, the idea for checking that checkbox was to let Oxygen know the edited file belonged to the DITA Document Type and thus show all available DITA toolbar actions and much more. Not everything is done through the CSS.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

anderszvensson
Posts: 71
Joined: Wed Jul 14, 2010 11:38 am

Re: CSS styling for specialization

Post by anderszvensson » Wed Sep 15, 2010 10:57 am

Ok, now I ran into a new problem... It works fine as long as I'm content with the default wysiwyg styling for dita. But, the problem is, I will have to modify this view somewhat, so I created a separate copy of the dita.css and the imported task.css.

But how do I use it in a template? I.e. I have a specialized topic type, and I have created a template for this type. I can of course associate with the new dita.css (named test.css), but that only works for the template itself. As soon as I create a new file from this template, the path in the css association is broken. I figure what would be needed is to use the "frameworks" variable you use in various settings dialogs, but I don't know how to do this in this scenario, since I only know how to associate a different css directly in the text view of the template.

Should this be done differently somehow?

Regards,

Anders

Radu
Posts: 6979
Joined: Fri Jul 09, 2004 5:18 pm

Re: CSS styling for specialization

Post by Radu » Wed Sep 15, 2010 11:07 am

Hi Anders,

Even if you can use editor variables in Oxygen file templates (and they will get expanded correctly after the file is created from the template) having a hard-coded reference to the modified CSS is not really an option.

You can edit the DITA document type from the Document Type Association Preferences page and in the Author tab you can modify the list of used CSS files.

If you edit and save the DITA document type as developer these changes will be stored in the OXYGEN_INSTALL_DIR\frameworks\dita\dita.framework configuration file. Then if you want others to share the same settings you will give them your entire OXYGEN_INSTALL_DIR\frameworks\dita\ directory contents to overwrite in their installation.
If you duplicate the DITA document type and edit it as such, the changes will be stored in Oxygen's local options.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

anderszvensson
Posts: 71
Joined: Wed Jul 14, 2010 11:38 am

Re: CSS styling for specialization

Post by anderszvensson » Thu Sep 23, 2010 5:11 pm

Hi,

I was wondering about the addition of the DTD to the catalog.xml. I have added the following to the catalog-dita.xml

Code: Select all

<public publicId="-//OASIS//DTD DITA Test//EN" uri="test.dtd"></public>
<public publicId="-//OASIS//ELEMENTS DITA Test//EN" uri="test.mod"></public>
It's under the group that specifies the relative path, just like the others in the catalog.xml file:

Code: Select all

<group xml:base="dtd/technicalContent/dtd/">
But I'm unclear as to the DTD reference in the xml files (in this case the template) that you mentioned. Because the reference requires the systemID as well as the publicID, but if I have to put the absolute path to the reference then it seems to sort of defeat the purpose, at least for the editor view... E.g.:

Code: Select all

<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Test//EN" "c:/dtds/test.dtd">
Supposedly, an XSL transformation processor like in the DITA OT will read the public ID first, so the catalog is some help there, but apparently the systemID is the only one used in the editor, the publicID doesn't seem to matter there, so I'm still stuck with having an absolute path there, right? Or am I missing something?

(Just like you have in your example:)

Code: Select all

<!DOCTYPE recipe PUBLIC RECIPE SYSTEM "recipe.dtd">
This would mean the editor will look for a "recipe.dtd" in the same catalog as the template file, right?

Regards,

Anders

anderszvensson
Posts: 71
Joined: Wed Jul 14, 2010 11:38 am

Re: CSS styling for specialization

Post by anderszvensson » Thu Sep 23, 2010 5:19 pm

Never mind! :-) I found the problem myself. Apparently the catalog reference did work in the editor, but I had just forgotten to change task to test in the name of the DTD...

Regards,

Anders

Radu
Posts: 6979
Joined: Fri Jul 09, 2004 5:18 pm

Re: CSS styling for specialization

Post by Radu » Thu Sep 23, 2010 5:31 pm

Right,

The DOCTYPE in the XML file should always be something like:

Code: Select all


<!DOCTYPE test PUBLIC "-//OASIS//DTD DITA Test//EN" "test.dtd">
because the system ID does not really matter if the public id is correctly mapped. The system id needs to be there because of validation constraints on DOCTYPEs.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Post Reply