Page 1 of 1

CSS Content through StylesFilter

Posted: Fri Nov 25, 2011 3:03 pm
by maxim.kovalev
At opening of file OxygenAutor uses following css for loading of pictures

Code: Select all

img {
...
content: url("http://localhost:8888/images/", attr(src));
...
}
It is necessary for me that css changed in a program operating time, therefore I have redefined StyleFilter and have connected it through Extensions

Code: Select all

public class DITAStylesFilter implements StylesFilter {	
private static final String IMAGE_TAG = "img";

@Override
public Styles filter (Styles styles, AuthorNode authorNode) {
if (AuthorNode.NODE_TYPE_ELEMENT == authorNode.getType() && IMAGE_TAG.equals(authorNode.getName())) {
try {
styles.setProperty(
Styles.KEY_PLACEHOLDER_CONTENT, new URL("http://localhost:8888/images/image.png"));
} catch (MalformedURLException e) {
e.printStackTrace();
}
}

return styles;
}

}
This filter is started, but replacement doesn't help. I can I specify incorrect parameter?
Thanks.

Re: CSS Content through StylesFilter

Posted: Fri Nov 25, 2011 3:18 pm
by mihaela
The Styles.KEY_PLACEHOLDER_CONTENT refers to the placeholder-content CSS property, that allows you to decide what content should be displayed in Author for an empty element.
If you want to control the content of the element you have to use Styles.KEY_MIXED_CONTENT property key:

Code: Select all


public Styles filter (Styles styles, AuthorNode authorNode) {
if (AuthorNode.NODE_TYPE_ELEMENT == authorNode.getType() &&
IMAGE_TAG.equals(authorNode.getName())) {
styles.setProperty(Styles.KEY_MIXED_CONTENT, new StaticContent[] {
new URIContent("http://www.oxygenxml.com/img/", "logo_oxygen.png")
});
}

return styles;
}
Regards,
Mihaela

Re: CSS Content through StylesFilter

Posted: Tue Mar 06, 2012 11:47 am
by maxim.kovalev
Hi, Mihaela
Styles.KEY_MIXED_CONTENT I set for image tag, and all works.

What style should be set for the tag attributes conref?

Code: Select all

public Styles filter (Styles styles, AuthorNode authorNode) {
if (AuthorNode.NODE_TYPE_ELEMENT == authorNode.getType()) {
if(((AuthorElement)authorNode).getAttribute("conref")!=null){
styles.setProperty(Styles.KEY_MIXED_CONTENT, new StaticContent[] {
new URIContent("http://localhost:8888/images/", "concept_Topic.dita#Topic_reference_1_6/testID")
});
}
}

return styles;
}
If I do so, then get an error:

Unsupported image type for 'localhost:8888/images/concept_Topic.dita#Topic_reference_1_6/testID'
See the help documentation for workarounds.
localhost:8888/images/concept_Topic.dita#Topic_reference_1_6/testID

Re: CSS Content through StylesFilter

Posted: Tue Mar 06, 2012 2:32 pm
by maxim.kovalev
I hope for your help

Re: CSS Content through StylesFilter

Posted: Tue Mar 06, 2012 3:19 pm
by mihaela
Hi Maxim,

Changing or setting the content reference cannot be done from the StylesFilter.
What you have to do is to create a References Resolver extension that can resolves the content referred by the DITA conref attribute.

Here is our online documentation about Configuring a References Resolver:
http://www.oxygenxml.com/doc/ug-editor/ ... olver.html

To add the reference resolver extension to your document type you can modify the Extensions bundle or you can add an individual Reference resolver extension (see Document Type dialog->Extensions tab).
For your reference resolver you can start from our DITA implementation (ro.sync.ecss.extensions.dita.conref.DITAConRefResolver). You can find the source code in oxygenAuthorSDK.zip, samples/Oxygen Default Frameworks directory.

Please let me know if need more information.

Best Regards,
Mihaela

Re: CSS Content through StylesFilter

Posted: Tue Mar 06, 2012 4:13 pm
by maxim.kovalev
Thanks, Mihaela

to add your StylesFilter I frameworks.zip your applet to add the following line dita.framework

Code: Select all

<field name="cssStylesFilterExtension">
<String> Ro.sync.ecss.extensions.api.DITAStylesFilter </ String>
</ field>
and that we should add to dita.framework, for my AuthorReferenceResolver?

I added

Code: Select all

<field name="customReferencesResolver">		<String>ro.sync.ecss.extensions.api.DITAReferenceResolver</String>
</field>
but it does not work

Re: CSS Content through StylesFilter

Posted: Tue Mar 06, 2012 5:23 pm
by mihaela
Hi Maxim,

ro.sync.ecss.extensions.api.DITAReferenceResolver is your Author refrence resolver implementation class?

Indeed, the Author reference resolver implementation class in stored in "customReferencesResolver" field in .frameworks file.

What do you mean by "it does not work"?
You could send us the error messages (if any) or applet console messages on our support email (support@oxygenxml.com). This could help us understand the source of your problem.

Regards,
Mihaela

Re: CSS Content through StylesFilter

Posted: Tue Mar 06, 2012 5:34 pm
by maxim.kovalev
Hi,

Yes, ro.sync.ecss.extensions.api.DITAReferenceResolver is my Author refrence resolver implementation class

"it does not work" - does not go not in one of the implementation methods

Re: CSS Content through StylesFilter

Posted: Tue Mar 06, 2012 5:43 pm
by mihaela
Is the jar that includes the ro.sync.ecss.extensions.api.DITAReferenceResolver class in the classpath (check the field named "classpath" from dita.frameworks)?

Regards,
Mihaela

Re: CSS Content through StylesFilter

Posted: Tue Mar 06, 2012 6:50 pm
by maxim.kovalev
I'm sorry, it was necessary to clear the cache

implemented everything on http://www.oxygenxml.com/doc/ug-editor/ ... olver.html

but it was an ode to the problem

in

Code: Select all

<author conref="concept_Topic_reference_1.dita#Topic_reference_1_6/testID">Test</author>
came all the contents of the document "concept_Topic_reference_1.dita"

and not a single element "Topic_reference_1_6/testID"

Re: CSS Content through StylesFilter

Posted: Tue Mar 06, 2012 7:36 pm
by maxim.kovalev
figured out
used class of DITAXMLReaderWrapper
thanks