On Tue, Jun 29, 2004 at 02:28:46AM -0400, Damien Fitzpatrick wrote: > I am running into a problem with the namespace for the > XIncludes. I am using the latest version of Xerces to process the XML > and hence the XIncludes. Unfortunately, when it inserts XIncludes XML > Mind uses the XInclude 2001 namespace: > xmlns:xi="http://www.w3.org/2001/XInclude". The problem with this is > that Xerces 2.6.2 will not process XIncludes with the 2001 namespace, > they must have the 2003 namespace, e.g.: > xmlns:xi="http://www.w3.org/2003/XInclude" > > Is there any way that XML Mind can be made to insert XIncludes with the > 2003 namespace?
Briefly, Xerces is using a now-deprecated XML namespace. In order to stay conformant into the future, you might be best served by having a flexible intermediate processing step to bridge the gap with your processor or processors. I will talk about the issues involved in more detail below. There are two major things to take into consideration when dealing with the XInclude specification. First, you have to get the namespace correct. The original namespace was <http://www.w3.org/2001/XInclude>, then, for a time, it became <http://www.w3.org/2003/XInclude>, and it has now been reverted to <http://www.w3.org/2001/XInclude>. This means, as you are seeing, that some processors which implemented the second namespace will need to be updated to stay conformant. XXE had not updated its processing to the second namespace. Effectively, this means that XXE intended to stay within the syntax and semantics of the first namespace (which is why the second namespace was created, to give users the choice). By reverting the newest specification to use the older namespace, the W3C is effectively saying that XInclude users should not use the older syntax and semantics. If they do, they will be non-conformant. As a result, in its current state, XXE is non-conformant by no fault of its own. Second, you have to deal with the XPointer component of the inclusion. This is where the conformance really makes a difference. Originally, you could place the XPointer after the # in a URL. In the <http://www.w3.org/2003/XInclude> namespace, this was changed so that the XPointer goes in its own attribute (xpointer). In the most recent revision (which reverts the namespace), this xpointer addition is maintained, so any users of the <http://www.w3.org/2001/XInclude> and the original syntax automatically are broken. This is the state of XXE. It uses the most recent XML namespace but not the most recent syntax and semantics. What you need, then, is a simple transformation to allow a processor still using the <http://www.w3.org/2003/XInclude> namespace to use the XIncludes from the current namespace with older syntax. For a somewhat naive implementation of this transformation, see the attachment. Obviously, you will not be able to use the output in XXE. The output is meant for use by Xerces. It could be easily adapted to update the old syntax to the new without changing the namespace, but I'll leave this as an exercise for the reader. You can use this from the command line or integrate it into an XXE macro. Take care, John L. Clark -------------- next part -------------- <?xml version="1.0"?> <!-- Here we use the xis prefix to mean "XInclude Standard" and the xi prefix to mean "XInclude" (the target output format). --> <stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" xmlns:xis="http://www.w3.org/2001/XInclude" xmlns:xi="http://www.w3.org/2003/XInclude" exclude-result-prefixes="#default xis" version="1.0"> <template match="/"> <apply-templates select="@*|node()"/> </template> <!-- Trivial identity transformation --> <template match="@*|node()"> <copy> <apply-templates select="@*|node()"/> </copy> </template> <template match="xis:include"> <variable name="nofrag" select="substring-before(@href, '#')"/> <variable name="xpointer" select="substring-after(@href, '#')"/> <xi:include href="{...@href}"> <choose> <when test="$nofrag"> <attribute name="href"> <value-of select="$nofrag"/> </attribute> </when> <otherwise> <attribute name="href"> <value-of select="@href"/> </attribute> </otherwise> </choose> <if test="$xpointer"> <attribute name="xpointer"> <value-of select="$xpointer"/> </attribute> </if> </xi:include> </template> </stylesheet> -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://www.xmlmind.com/pipermail/xmleditor-support/attachments/20040629/30c93088/attachment.sig

