attr() as argument in oxy_substring

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

attr() as argument in oxy_substring

Post by xmlman »

Can the attr() be used as the value for the text using oxy_substring CSS function? I need to eliminate part of the xlink:href value of my <link> element to create links in Author. The syntax of the value must be maintained due to propriety IETM publishing software. My link element looks like this:

<link xlink:href="IETM://M00033" xmlns:xlink="http://www.w3.org/1999/xlink"><prompt>PROMPT TEXT</prompt></link>

I need to grab the substring "M00033" for file name of the linked to file.

I have tried the following:
link:before {link: oxy_substring(attr(xlink|href),7)".xml";}

and I have tried:

link:before {link: oxy_xpath("substring-after(attr(xlink|href),'IETM://')".xml";}

Neither method using Oxygen CSS custom extension functions is working. Is what I'm trying to do possible?
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Re: attr() as argument in oxy_substring

Post by Radu »

Hi Charles,

The main problem is that Oxygen contributes to each Author page with an implicit CSS file which contains this implicit rule:

Code: Select all

*[xlink|href]:before {
content:url(../images/link.gif);
link: attr(xlink|href) !important;
}
Because this implicit contributed rule is marked as !important it overrides the property that you have set in your CSS file.

The workaround is to also mark your link property as important like:

Code: Select all

link:before {
link: oxy_concat(oxy_substring(attr(xlink|href), 7), ".xml") !important;
content: "LINK";
text-decoration:underline;
color:blue;
display:inline;
}
Of course you also have to declare a namespace mapping at the beginning of your CSS file:

Code: Select all

@namespace xlink url('http://www.w3.org/1999/xlink');
The alternative using XPath should have been like:

Code: Select all

link: oxy_xpath("//*[@xlink:href]/substring-after(@xlink:href,'IETM://')") ".xml" !important;
It does not properly work because when executing the XPath we should also declare mappings for the prefixes currently defined in the CSS files. I added an improvement request for this.
To make this work using the XPath expression for now you can use a more generic construct like:

Code: Select all

 link: oxy_xpath("//*[@*:href]/substring-after(@*:href,'IETM://')") ".xml" !important;
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Re: attr() as argument in oxy_substring

Post by Radu »

Hi,

Oxygen 13.2 which has just been released will try to map prefixes defined in the CSS xpath function by also looking at namespace mappings declared in the CSS file.

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