oxy_xpath not evaluating for xi:include elements/attributes in parent document

Oxygen general issues.
sladeshelton
Posts: 2
Joined: Wed Jan 02, 2013 11:58 pm

oxy_xpath not evaluating for xi:include elements/attributes in parent document

Post by sladeshelton »

I am trying to use the oxy_xpath CSS function to grab an attribute and set it as the content for my projects CSS file. It works fine in the xml document where the element and attribute are, but does not work as expected in the parent xml document where I use xi:include to reference the xml instance. From my research (Link to previous forum post), this seems to be a known issue. I wasn't sure if there was another work around for getting the oxy_xpath function to grab the referenced attribute.
Radu
Posts: 9051
Joined: Fri Jul 09, 2004 5:18 pm

Re: oxy_xpath not evaluating for xi:include elements/attributes in parent document

Post by Radu »

Hi,

The oxy_xpath works over a DOM source which has the xi:include references not expanded (and thus not transparent).
You could try to parse the @href's yourself in the oxy_xpath, something like:

Code: Select all

article:before{
content:oxy_xpath('//xi:include/doc(@href)//@id | //@id');
}
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
sladeshelton
Posts: 2
Joined: Wed Jan 02, 2013 11:58 pm

Re: oxy_xpath not evaluating for xi:include elements/attributes in parent document

Post by sladeshelton »

Thank you for the feedback and insight.

I found another option to grab the attribute values that seems to do the trick. Instead of the oxy_xpath function, I noticed the oxy_attributes() function returned the values I needed (along with the attribute name). This got me thinking and I tried the attr() function with the applicable attribute name and it works as expected.

The hurdle I encountered with the xpath example was it returned all @id's in my document, when I just wanted the @id value for each applicable element as the CSS was being applied to my document. I probably did not provide enough details in my initial post. My xml looks like this

root document:

Code: Select all


  <fleets>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="deferrals1.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="deferrals2.xml"/>
</fleets>
deferrals1.xml:

Code: Select all


  <fleet>
<deferrals>
<deferral id="value1"/>
</deferrals>
</fleet>
deferrals2.xml:

Code: Select all


  <fleet>
<deferrals>
<deferral id="value2"/>
</deferrals>
</fleet>
The oxy_xpath was giving me both @id values at each deferral element with I was setting the content of the deferral element via CSS. Now I'm setting the content of the deferral element to attr(id) in the CSS and the value I need is being grabbed.

Thanks again for the explanation and feedback.
Radu
Posts: 9051
Joined: Fri Jul 09, 2004 5:18 pm

Re: oxy_xpath not evaluating for xi:include elements/attributes in parent document

Post by Radu »

Hi,

I thought exactly the opposite, that you wanted to gather all IDs from all referenced modules.
Yes, using the attr() function is enough (and the usual way) to give you the value of an attribute defined on that element which is matched by the CSS selector:
http://www.oxygenxml.com/doc/ug-oxygen/ ... ction.html

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