OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   XLink, XInclude, and xml:base

[ Lists Home | Date Index | Thread Index ]
  • To: <xml-dev@lists.xml.org>
  • Subject: XLink, XInclude, and xml:base
  • From: "Magnus Henriksson (MO/EAB)" <magnus.henriksson@ericsson.com>
  • Date: Tue, 27 Sep 2005 16:46:52 +0200
  • Thread-index: AcXDckyQcEfD0gh6S6ydakbHBmydbw==
  • Thread-topic: XLink, XInclude, and xml:base

Hi all,

I need some help understanding the interaction between XLinks, XInclude, and xml:base.


Assume I have the following document.xml:

<?xml version="1.0"?>
<document xml:base="http://example.com";
          xmlns:xi="http://www.w3.org/2001/XInclude";>
  <paragraph>How to handle customers:</paragraph>
  <xi:include href="common/policy.xml"/>
</document>


policy.xml looks like this:

<?xml version="1.0"?>
<list xmlns:xlink="http://www.w3.org/1999/xlink";>
  <item xml:id="item1">The customer is always right.</item>
  <item>When the customer is wrong, see <link xlink:type="simple"
                                              xlink:href="#item1"/>.</item>
  <graphic xlink:type="simple"
           xlink:actuate="onLoad"
           xlink:show="embed"
           xlink:href="../images/happy-customer.gif"/>
</list>


If run document.xml through an XInclude processor, I get the following result:

<?xml version="1.0"?>
<document xmlbase="http://example.com";
          xmlns:xi="http://www.w3.org/2001/XInclude"; >
  <paragraph>How to handle customers:</paragraph>
  <list xmlns:xlink="http://www.w3.org/1999/xlink";
        xml:base="common/policy.xml">
    <item xml:id="item1">The customer is always right.</item>
    <item>When the customer is wrong, see <link xlink:type="simple"
                                                xlink:href="#item1"/>.</item>
    <graphic xlink:type="simple"
             xlink:actuate="onLoad"
             xlink:show="embed"
             xlink:href="../images/happy-customer.gif"/>
  </list>
</document>


My problem is that the link points to http://example.com/common/policy.xml#item1, but I really want it to point to #item1 in the XIncluded result. The graphic points to http://example.com/images/happy-customer.gif which is what I want.

In this simple example, it would be quite easy to resolve the full URL of the graphic and then remove all xml:base attributes (e.g. using a transform, SAX, ...). Using this method, I can transform URLs in different elements to something that makes sense to me. So far, so good? What I cannot understand, is how you do something like this when using more complex inclusions and XLinks.


For example, assume I have the following document2.xml:

<?xml version="1.0"?>
<document xml:base="http://example.com";
          xmlns:xi="http://www.w3.org/2001/XInclude";>
  <paragraph>How to handle customers:</paragraph>
  <list>
    <xi:include href="common/policy2.xml"
                xpointer="xpointer(list/*)"/>
  </list>
</document>


policy2.xml looks like this:

<?xml version="1.0"?>
<list xmlns:xlink="http://www.w3.org/1999/xlink";>
  <item xml:id="item1">The customer is always right.</item>
  <item>When the customer is wrong, see <link xlink:type="simple"
                                              xlink:href="#xpointer(list/item[1])"/>.</item>
  <graphic xlink:type="simple"
           xlink:actuate="onLoad"
           xlink:show="embed"
           xlink:href="../images/happy-customer.gif"/>
</list>


If run document2.xml through an XInclude processor, I get the following result:

<?xml version="1.0"?>
<document xml:base="http://example.com";
          xmlns:xi="http://www.w3.org/2001/XInclude";>
  <paragraph>How to handle customers:</paragraph>
  <list>
    <item xml:id="item1"
          xml:base="common/policy2.xml">The customer is always right.</item>
    <item xmlns:xlink="http://www.w3.org/1999/xlink";
          xml:base="common/policy2.xml">When the customer is wrong, see <link xlink:type="simple"
                                                                              xlink:href="#xpointer(list/item[1])"/>.</item>
    <graphic xmlns:xlink="http://www.w3.org/1999/xlink";
             xlink:type="simple" xlink:actuate="onLoad"
             xlink:show="embed" xlink:href="../images/happy-customer.gif"
             xml:base="common/policy2.xml"/>
  </list>
</document>


Now what? If I simply remove the xml:base attributes, the XPointer in <link> will not point to anything. It would need to be changed into, for example, xpointer(document/list/item[1]). This whole thing quickly gets very complex when you start adding sophisticated XIncludes and XLinks, and XLinks between documents or parts of documents that sometimes are included, sometimes not.

OK, what I seem to be looking for: Is there a way to determine whether an XLink points to something that is part of the current XIncluded result? And if I'm so lucky, is there a way to update those XLinks to point the corresponding thing in the XIncluded result? Or am i just nuts?



// Magnus

-- 
Magnus Henriksson        Ericsson AB
+46 31 747 6933          Transmission & Transport


This communication is confidential and intended solely for the addressee(s). Any unauthorized review, use, disclosure or distribution is prohibited. If you believe this message has been sent to you in error, please notify the sender by replying to this transmission and delete the message without disclosing it. Thank you.

E-mail including attachments is susceptible to data corruption, interruption, unauthorized amendment, tampering and viruses, and we only send and receive e-mails on the basis that we are not liable for any such corruption, interception, amendment, tampering or viruses or any consequences thereof.




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS