cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Xinclude and the DOM

ClayHelberg
17-Peridot

Xinclude and the DOM

Hi Adepters/PTC
gurus--


I have a question:
I'm trying to add some customizations to make it easier to work with Xincludes
in Epic/Arbortext Editor. One thing I wanted to do was create a list of
Xincludes in the current document. But I'm having trouble accessing the xinclude
elements in my document. If I walk the document tree, I can see the parent
document's elements, and the imported fragment's elements, but not the xinclude
element itself. With file entities, the imported elements appear within an
entity reference node, but no such wrapper node seems to exist for
xincludes.


Similarly, the ACL
find functions don't seem to be able to find xinclude
markup.


So, can anyone tell
me how I can scan the document for the xinclude references, either using DOM
methods or using ACL? Thanks.


class=569550114-24082006>
--Clay
3 REPLIES 3

Has anyone found a solution to this since this post last summer?

Steve

Helberg, Clay wrote:
> Hi Adepters/PTC gurus--
>
> I have a question: I'm trying to add some customizations to make it
> easier to work with Xincludes in Epic/Arbortext Editor. One thing I
> wanted to do was create a list of Xincludes in the current document.
> But I'm having trouble accessing the xinclude elements in my document.
> If I walk the document tree, I can see the parent document's elements,
> and the imported fragment's elements, but not the xinclude element
> itself. With file entities, the imported elements appear within an
> entity reference node, but no such wrapper node seems to exist for
> xincludes.
>
> Similarly, the ACL find functions don't seem to be able to find
> xinclude markup.
>
> So, can anyone tell me how I can scan the document for the xinclude
> references, either using DOM methods or using ACL? Thanks.
>
>
> --Clay

I haven't been able to find a solution, but apparently I have managed to fall into the same trap. I have been combing the help files for the last two days and have not been able to find a way to access XInclude references in a document. The XPath functions don't even work. I find it strange (not to mention frustrating) that there are a ton of ACL functions for file entities, but none for XIncludes.

Ryan

In Reply to steve.cuzner:

Has anyone found a solution to this since this post last summer?

Steve

@Helberg, Clay wrote:
> Hi Adepters/PTC gurus--
>
> I have a question: I'm trying to add some customizations to make it
> easier to work with Xincludes in Epic/Arbortext Editor. One thing I
> wanted to do was create a list of Xincludes in the current document.
> But I'm having trouble accessing the xinclude elements in my document.
> If I walk the document tree, I can see the parent document's elements,
> and the imported fragment's elements, but not the xinclude element
> itself. With file entities, the imported elements appear within an
> entity reference node, but no such wrapper node seems to exist for
> xincludes.
>
> Similarly, the ACL find functions don't seem to be able to find
> xinclude markup.
>
> So, can anyone tell me how I can scan the document for the xinclude
> references, either using DOM methods or using ACL? Thanks.
>
>
> --Clay

Hi Ryan and Steve-



I did solve this, with some help from PTC developers (props to Sam Brow and
the still-missed PG Bartlett), but I guess I neglected to follow up with the
list. Sorry about that.



Apparently the only way to do it is to scan all the OID's in the document
and check each one's include properties. Here's a quick function to return
an array of all the Xinclude OIDs in a document:



function getXincludeOIDs($oids[],doc=current_doc()) {

delete($oids);

if (!doc_valid(doc) || doc_kind(doc) != 'xml') {

return;

}

local o = oid_root(doc);

while(oid_valid(o)) {

if (oid_encl_include(o) == o) {

# it's an xinclude, so add it to the array

$oids[count($oids)] = o;

}

o = oid_forward(o);

}

}



Once you've got an OID for an Xinclude, you can get its filename using the
dobj_logicalid() function.



Good luck!



--Clay



Clay Helberg

Senior Consultant

TerraxXML


Announcements