Show image in Authoring mode
-
- Posts: 53
- Joined: Tue Aug 23, 2005 12:00 pm
Show image in Authoring mode
I have XML content like:
<image name="SomeSVG">
<caption>blah blah</caption>
</image>
How can my CSS (that renders the authoring layout) display the image in the name attribute?
I am trying something with background-image, but i then also need to add the base of the XML to the filename and concat with the name attribute.
Tx.,
Raphael
-
- Posts: 501
- Joined: Mon Feb 03, 2003 10:56 am
Re: Show image in Authoring mode
Here it is a working sample.
The XML file - "test.xml":
-------------
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="test.css"?>
<test>
<image name="svg/animate-elem-04-t.svg">
<caption> Hello </caption>
</image>
</test>
-------------
The CSS file - "test.css":
-------------
test{
display:block;
}
image{
display:block;
content:attr(name, url);
}
caption{
display:block;
}
-------------
You can download the SVG file from: http://www.w3.org/Graphics/SVG/Test/200 ... m-04-t.svg
You must provide the attr function the type of the object to be returned: in our case "url". In this way the editor will try to create an image by analysing the content type of the url. The paths from the XML file do not have to be absolute. The attr function will solve the url relative to the XML base.
For more information, see the oXygen User Guide:
http://www.oxygenxml.com/doc/ug-oxygen/ ... ction.html
Best regards,
Dan
-
- Posts: 501
- Joined: Mon Feb 03, 2003 10:56 am
Re: Show image in Authoring mode
The good news are that starting from the version 9.2 (that will be released at the beginning of May), there will be support for the recursive evaluating of functions.
In your case, the expression will be like:
Code: Select all
content:url(concat('../images' attr(name)));
The XML file - "test.xml":
-------------
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="test.css"?>
<test>
<image name="animate-elem-04-t.svg">
<caption> Hello </caption>
</image>
</test>
-------------
The CSS file - "test.css":
-------------
test{
display:block;
}
image{
display:block;
content: url(concat("svg/", attr(name)));
}
caption{
display:block;
}
-------------
For the moment, the only thing you could do is either modify the XML file so that the name attributes would contain correct relative paths to the SVG files, or make a copy of the SVG files in the XML file directory.
Cheers,
Dan
-
- Posts: 53
- Joined: Tue Aug 23, 2005 12:00 pm
Re: Show image in Authoring mode
Thanks again for the quick response.
I can't change the XML nor can i copy the image files, this is a mandatory structure for our system. That leaves postponing this as an alternative. I will wait for the 9.2 release.
Again, tx!
Raphael
-
- Posts: 501
- Joined: Mon Feb 03, 2003 10:56 am
Re: Show image in Authoring mode
I have just uploaded a new beta kit for the oXygen 9.2. If you want to try it, you can download it from:
http://www.oxygenxml.com/update/oxygen.tar.gz
After extracting it, you should use one of oxygen.sh or oxygen.bat to start it. I assume you have Java 1.5 or 1.6 installed on your computer. Please note that this distribution may be unstable.
Best regards,
Dan
-
- Posts: 501
- Joined: Mon Feb 03, 2003 10:56 am
Re: Show image in Authoring mode
The url function is working correctly resolving relative references to the CSS. It might be used for loading images used as decorators. We solved the problem using another two functions:
document-url() - returns the URL of the document - in fact of the XML element the CSS rule applies.
parent-url() - returns the parent URL - eg: file:/a/b/c.xml -> file:/a/b/
So, you can use them like this:
Code: Select all
image{
display:block;
content:url(concat(parent-url(document-url()) "../images" attr(name)));
}
http://www.oxygenxml.com/update/oxygen.tar.gz
If you have other problems do not hesitate to contact us.
Best regards,
Dan
-
- Posts: 1
- Joined: Mon Jun 02, 2008 3:15 pm
Re: Show image in Authoring mode
You mentioned above that we should should use the following code to resolve Raphaels question
Code: Select all
image{
display:block;
content:url(concat(parent-url(document-url()) "../images" attr(name)));
}
Code: Select all
<test>
<image name="image1.png">
<caption>image 1</caption>
</image>
<image name="image2.png">
<caption>image 2</caption>
</image>
</test>
do you have any advice ?
Peter
-
- Posts: 501
- Joined: Mon Feb 03, 2003 10:56 am
Re: Show image in Authoring mode
Code: Select all
image{
display:block;
content:url(
concat(
parent-url(document-url())
concat("../images/")
attr(name) ));
}
Best regards,
Dan
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Show image in Authoring mode
Post by sorin_ristache »
The base URL of the XML document displayed in Author mode can be obtained in the CSS stylesheet with
Code: Select all
parent-url(document-url())
Regards,
Sorin
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Show image in Authoring mode
Post by sorin_ristache »
The function document-url() returns the base URL of the current node of the XML document. Of course this is the same as the URL of the document if you do not change the base URL of an XML element with an xml:base attribute added to that element. We should rename the function to base-url().
Regards,
Sorin
-
- Posts: 53
- Joined: Tue Aug 23, 2005 12:00 pm
Re: Show image in Authoring mode
Our XML documents which bare an xml:base attribute (http://www.w3.org/TR/xmlbase/) don't seem to work correctly.
Are you sure the document-url() respects any xml:base values?
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Show image in Authoring mode
Post by sorin_ristache »
content: document-url();
the Author node displays the URL set by the xml:base attribute. If it does not work for you please post small samples of your XML and CSS files.
Regards,
Sorin
-
- Posts: 53
- Joined: Tue Aug 23, 2005 12:00 pm
Re: Show image in Authoring mode
My xsml:base is:
Code: Select all
xml:base="../../"
We use this base value successfully in our XSL documents.
When i set the base like:
Code: Select all
xml:base="../somedoc-in-headdir.xml"
Is my base value invalid, or is the CSS function not working correctly?
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Show image in Authoring mode
Post by sorin_ristache »
Code: Select all
xml:base="../images/"
Regards,
Sorin
-
- Posts: 53
- Joined: Tue Aug 23, 2005 12:00 pm
Re: Show image in Authoring mode
Code: Select all
content:url(
concat(
parent-url(document-url())
concat("/images/")
attr(name) ));
The xml:base on files in the head/sub/somefile.xml make sure the standard resolution of image URIs works.
In XSL we use the following XPath expression:
Code: Select all
resolve-uri(concat('images/',@name),base-uri())
Is there something like resolve-uri in your extension. Writing your own CSS function would be very helpful

tx.,
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Show image in Authoring mode
Post by sorin_ristache »
In that case I think you need to remove the first '/' from "/images/":rparree wrote:The xml:base on files in the head/sub/somefile.xml make sure the standard resolution of image URIs works.
In XSL we use the following XPath expression:
Code: Select all
resolve-uri(concat('images/',@name),base-uri())
Code: Select all
content:url(
concat(
parent-url(document-url())
concat("images/")
attr(name) ));
Code: Select all
resolve-uri(concat('images/',@name),base-uri())
Regards,
Sorin
-
- Posts: 53
- Joined: Tue Aug 23, 2005 12:00 pm
Re: Show image in Authoring mode
I am sorry to say that it did not work. I believe it is all because i am not implementing the resolve-uri XPath function using the parent-url(document-url())combination.
When the base is "../../" (xml = library/book/chapters/chapter.xml) then the my relative URI resolves one directory to high. In this case the base is a path and therefore the document-url() would be sufficient. (It resolves to library/images/ where it should resolve to library/book/images)
When the base is library/book/book.xml then the parent-url is needed to resolve the images relative to somerootdir/somedir/images.
This is all done in XPath using the resolve-uri
(The idea is that sometimes "chapters" are in separate files and are xincluded into the book.xml; all images however are in chapter/images. So whether i am in library/book/chapters/chapter.xml or in library/book/book.xml the images should resolve, therefor we place the xml:base on the chapter.xml)
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Show image in Authoring mode
Post by sorin_ristache »
I understand that all images for library/book/book.xml and library/book/chapters/chapter.xml are located in library/book/images. In that case the xml:base attribute of chapter.xml should specify xml:base="../" instead of xml:base="../../".rparree wrote:It resolves to library/images/ where it should resolve to library/book/images
...
So whether i am in library/book/chapters/chapter.xml or in library/book/book.xml the images should resolve, therefor we place the xml:base on the chapter.xml)
With xml:base="../../" used in chapter.xml the result of concat(parent-url(document-url()) concat("images/") attr(name)) and resolve-uri(concat('images/',@name),base-uri()) is the same: library/images/imageFile.gif where I assumed that the name attribute is name="imageFile.gif". I do not understand how resolve-uri(concat('images/',@name),base-uri()) returns library/book/images/imageFile.gif. Can you post small sample files book.xml, chapter.xml, a sample XSLT stylesheet and a sample CSS stylesheet for reproducing the problem?
Regards,
Sorin
-
- Posts: 53
- Joined: Tue Aug 23, 2005 12:00 pm
Re: Show image in Authoring mode
Can i send or upload an example (this way you get the correct directory structure) I have also include some Java code that transforms the XML using SAXON and Xerces XInclude processing.
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Show image in Authoring mode
You can zip the sample files and send them to our techical support email.
http://www.oxygenxml.com/techSupport.html
Regards,
Radu
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Show image in Authoring mode
Post by sorin_ristache »
Waiting for your CSS example,
Sorin
-
- Posts: 53
- Joined: Tue Aug 23, 2005 12:00 pm
Re: Show image in Authoring mode
I have updated the book.xml like
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="../../../xsl/wysiwyg.css"?>
<book xmlns:xi="http://www.w3.org/2001/XInclude">
<chapter id="inline">
<image name="foo.gif"/>
</chapter>
<xi:include href="chapters/loose-chapter.xml"/>
</book>
Code: Select all
image{
display:block;
content:url(
concat(
parent-url(document-url())
concat("images/")
attr(name) ));
margin-top: 15px;
}
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Show image in Authoring mode
Post by sorin_ristache »
Regards,
Sorin
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Show image in Authoring mode
Post by sorin_ristache »
Regards,
Sorin
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service