Pages: 1
Print
Author Topic: relative paths in css files  (Read 4646 times)
rewers08
Member

Posts: 9


« on: November 24, 2010, 05:35:31 AM »

Hi,

We are having a problem with XMAX in version 6.5.

In our XMAX customization we are using css to show images before a certain tag. That works fine so far. The problem is that right now we do it with absolut paths to the images' location. Unfortunatly we have to use relative paths. We were hoping that the relative path would be relative to the xml file that is being edited in XMAX. But that seems not to be the case. If the path should be relative to the css file we might have a problem because the css file is inside the .xac file that is generated by the XMetaL Developer.

Can somebody give me a hint how we could use relative paths in the css files? To what position in the file system is the path relative?

Thanks in advance,
rewers08.
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2606



WWW
« Reply #1 on: November 25, 2010, 05:28:49 PM »

Paths in CSS files are always relative to the CSS file itself.

That is the way things are supposed to work anyway. So, if all of your files are in the same folder (which they should be if distributed via XAC file because XAC when unpacked puts everything into the same folder) then simply include the filename without any folders at all to create a relative path.

That having been said, if this doesn't work for a particular case please provide details so we can try to reproduce the problem.
Logged
rewers08
Member

Posts: 9


« Reply #2 on: November 26, 2010, 02:08:33 AM »

Thanks for your reply.

The problem is a bit more tricky and our XMAX is behaving a little bit different from what you've explained. We have a folder in which we put the to be opened xml file and the xac file. The problem is that XMAX decompresses the xac file in a totally different folder (in the "local settings" folder inside the "documents and settings" folder). But we have already found a workaround to that problem:

1. we've defined a "variable" inside the css file for the path to the images (css doesn't support variables so we've just put the String "LOGO_PATH" into "$" signs -- $LOGO_PATH$).
2. the XMAX scripting api gives access to the styles defined inside the css file. So on the "ON_DOCUMENT_OPEN_COMPLETE" event we parse the css file and exchange all occurences of the "variable" with the actual path.

So far that's just the theory. I am not through with the implementation. I will let you know if it works.

Greetings,
rewers.
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2606



WWW
« Reply #3 on: November 26, 2010, 08:19:17 PM »

I think I'm probably not able to give you a very good answer here because I don't know which images you are referring to. If these images are referenced by the CSS file then simply placing them inside the XAC file should resolve your issue (as the CSS file and the images will be unpacked to the same folder).

Are you using something like this in your CSS?:

elementName:before {
  content: url(image.jpg);
}


If you must store the images in a location outside of your XAC files then you are going to have problems using XAC (as you have seen) when referencing from CSS using a relative path. If the images are always in the same place on everyone's machine perhaps you can use a full path?

Another solution that might work for you is to not use a XAC file in this case. Place your DTD and CSS in the same folder along with your other customization files. If the CSS file has the same name as the DTD (ie: filename.dtd, filename.css, filename.ctm, filename.mcr) it will be found. If you do not use XAC then the location of the customization (DTD, CSS and other files) will not change because there is no need to extract the files from the XAC (there is no XAC). You might need to change your XMAX startup code (loadFromFile / loadFromString) so that it does not use the XAC parameter. In this case, in order to find the DTD you will need to encode that as part of the SYSTEM id in the DOCTYPE declaration in the XML.

Hope this helps. I'm still not sure exactly what you are doing, so I might be way off base here.
« Last Edit: November 26, 2010, 08:23:18 PM by Derek Read » Logged
Pages: 1
Print
Jump to:  

email us