Solved

XLink, XPointer, XInclude, and Saxon

Posted on 2009-05-05
8
715 Views
Last Modified: 2013-11-18
I have a rough understanding as to what XLink is (in terms of @type='simple' at least).

What is XPointer and XInclude? I keep seeing their names pop up?

Are these compatible with SaxonB?
0
Comment
Question by:numberkruncher
  • 5
  • 3
8 Comments
 
LVL 20

Expert Comment

by:ChristoferDutz
ID: 24307418
XLink is used to define links between indivudual xml documents. You can think of them as cooler a-tags you know from HTML. You can define unidirectional and bidirectional relations between data. I guess Saxon has nothing to do with that.

Xinclude is used to assemble Xmldocuments by "importing" other (not necesarily xml) documents. Here an example from Wikipedia:
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:xi="http://www.w3.org/2001/XInclude">
   <head>...</head>
   <body>
      ...
      <p><xi:include href="license.txt" parse="text"/></p>
   </body>
</html>

XPointer is an alternative to XPath in adressing and referencing nodes in a Xml Document. It can be thought of something similar to XPath.

I doubt that Saxon implements the XPointer stuff and I have read that is supports XInclude partially.
0
 
LVL 13

Author Comment

by:numberkruncher
ID: 24308814
I think that I understand XInclude now...it is a process which occurs prior to an XSLT transform to include externally referenced content.

Here is where I am getting confused. From information that I have found on several websites:

XPointer:
  > Uses XPath to locate content within a document.
  > Can be used as the fragment part of a URI. I am not sure how this part gets resolved/processed by an XSLT 2.0 transform?

XLink:
  > Apparently XPointer can be used within the "xlink:href" attribute.

XInclude:
  > Apparently XPointer is used within one of the attributes of XInclude to locate XML content.


I have tried using the XPath expression "document('myFile.xml#id1')" with the SaxonB processor, and it does appear to locate the correct XML content. Is this standard of all XSLT 2.0 processors? Are there more XPointer functions that can be used by the "document" function of XSLT 2.0 processors? Am I going about this in the wrong way?
0
 
LVL 20

Expert Comment

by:ChristoferDutz
ID: 24313619
Ok as far as I have googled, XPointer extends XPath with some features that can be used for expressions, that were not expressable in ordinary XPath. I think this is therefore not addressed by the Xsl-transofmer, but the parser used for the xsl-transformation.

Seems like the parser used by Saxon, as it also supports Xpath2.0, seems to support at least a subset of XPointer.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 13

Author Comment

by:numberkruncher
ID: 24320945
Do you know of a complete XSLT implementation (preferably 2.0, and Saxon compatible) of XPointer?

Whilst ideally I would like to have support of the W3C recommended XPointer schemes, I would rather like "xmlns()", "element()", and the non-W3C "xpath1()" scheme support.
0
 
LVL 20

Expert Comment

by:ChristoferDutz
ID: 24323341
Well As I am only aware of Saxon as fully Xslt2.0 comatible Implementation.

An Eifel implementation of a rudimentry XSLT2.0 Processor: http://sourceforge.net/projects/gestalt/

A tool from Altova: http://www.altova.com/altovaxml.html

Microsoft seems to have started to work on one back in 2006, but I have never heard of a finished implementation.

I'd suggest sticking to Saxon.
0
 
LVL 20

Expert Comment

by:ChristoferDutz
ID: 24323360
Argh, just saw that I totally misread your post ... here is a list (don't know how fresh it is and how complete):
http://www.w3.org/XML/2002/10/LinkingImplementations.html
http://www.cs.unibo.it/~fabio/XPointer/

But I have to admit, that all I could find was a lot of posts about mobody being able to find a xomplete XPointer implementation for Java.
0
 
LVL 13

Author Comment

by:numberkruncher
ID: 24323560
I have had a read through the links above, but I was unable to find an XSLT implementation.

I have started to write my own implementation for this, but am having major difficulties with one part. If I can work around this difficulty I think that I can come up with an implementation which supports "xpath1()", "xmlns()", and "element()".....but probably not the "xpointer()" scheme.

The problem that I am having is with "xmlns()".

For example, the URL:

http://example.com/something.xml#xmlns(abc=http://www.example.com) xpath1(//abc:test)

My implementation of the "xpath1" scheme is working, but it refuses to recognize the "abc" prefix.

I have tried constructing a temporary node set in XSLT which includes all of the specified namespaces, and this much works, BUT I cannot find a way of getting the "document()" XPath function to recognize these namespaces.

Is there a workaround to this problem? Essentially I need to dynamically register prefixes in the context of the external document to fix this problem.......or alternatively find a complete implementation of XPointer/XInclude written in XSLT.

<xsl:variable name="temp-context">
   <!-- constructs an element with all of the 'xmlns()' added -->
</xsl:variable>
 
<!-- Move into $temp-context so that namespaces are in the current context -->
<xsl:for-each select="$temp-context">
   <xsl:sequence select="document($locator-path)/saxon:evaluate($xpath-expr)"/>
</xsl:for-each>

Open in new window

0
 
LVL 20

Accepted Solution

by:
ChristoferDutz earned 500 total points
ID: 24325087
Maybe you should close this topic and open a new one, as this seems to deal with an entirely diffrernt problem. I think the original Question is solved but with your current question, I can no longer support you :-(

I doubt that any expert will look into such an old discussion, so I'd suggest to close this one and ask your new Question.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question