General XMetaL Discussion
rewers08 November 24, 2010 at 11:35 am
relative paths in css filesNovember 24, 2010 at 11:35 amParticipants 2Replies 3Last Activity 12 years, 2 months ago
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.Derek Read November 25, 2010 at 11:28 pm
Reply to: relative paths in css filesNovember 25, 2010 at 11:28 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.rewers08 November 26, 2010 at 8:08 am
Reply to: relative paths in css filesNovember 26, 2010 at 8:08 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.
rewers.Derek Read November 27, 2010 at 2:19 am
Reply to: relative paths in css filesNovember 27, 2010 at 2:19 am
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?:
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.
- You must be logged in to reply to this topic.