Resolving paths

Oxygen general issues.
xmlman
Posts: 13
Joined: Wed Oct 12, 2011 7:51 pm

Resolving paths

Post by xmlman »

I need to build on my previous post for using oxy_substring and an attribute. That part is now working fine.

Now that I can grab the value of xlink:href after "IETM://" I need to resolve what folder in which XML file resides.

EXAMPLE XML:

<link xlink:href="IETM://O0013"/>

<link xlink:href="IETM://M0024"/>

<link xlink:href="IETM://T0024"/>

If the current file I'm editing is say M0013.xml, then of the three links, M0024.xml is in my current folder. However both the first and third files O0013 and T0024 are in different sibling folders.

From the first letter of the file name I know which folder the file in. For instance, O0013 is the "Operator Instructions" folder. T0024 is in the Troubleshooting folder.

Code in my current CSS that grabs the value of attribute "xlink:href":

link:before {
link: oxy_substring(attr(xlink|href), 7)".xml" !important;
content:url(img/link.png);
}

I've found that if I'm currently editing a Maintenance file, this will open a file in Operator folder:

link:before {
link: oxy_concat('../Operator Instructions/',oxy_substring(attr(xlink|href), 7))".xml" !important;
content:url(img/link.png);
}

However I need to be able to make a decision on what folder to retrieve a file from based the the first letter of the substring result.

Is this possible within CSS? or would this require some kind of Java programming?

Thanks.

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

Re: Resolving paths

Post by Radu »

Hi Charles,

CSS 3 has a selector type which would be useful in this case:

Code: Select all

E[foo^="bar"] 	an E element whose "foo" attribute value begins exactly with the string "bar" 
but Oxygen does not yet support this selector. I added an improvement request for a future version for this.

In the meantime you could try to implement this using the oxy_xpath, something like this sample:

Code: Select all

@namespace xlink "http://www.w3.org/1999/xlink";

link[xlink|href]:before {
link: oxy_xpath("if (starts-with(substring-after(@*:href,'IETM://'), 'O')) then concat('../Operator Instructions/', substring(@*:href, 7), '.xml') else (if(starts-with(substring-after(@*:href,'IETM://'), 'T')) then '2' else '3') ") !important;
content: "TEST" !important;
}
Mihaela already sent you an all platforms Oxygen kit with some xpath-related issues that you reported fixed.

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