0
votes

XSL requires this at the top of every stylesheet:

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

and throws an error if the url in the namespace is not exactly right.

Today, "http://www.w3.org/1999/XSL/Transform" is offline. I cannot run any transformations. The transformation hangs and then returns "unexpected end of file" when the net request times out. If I change the URL in the namespace declaration to a random URL, the transformation fails with an error telling me that "http://www.w3.org/1999/XSL/Transform" is the required xsl namespace.

So how do I work around W3's site being down?

2
It's not failing because "w3.org/1999/XSL/Transform" is unavailable. It's failing for some other reason. Perhaps because the XHTML DTD is being requested.Michael Kay
Instead of throwing to us a vague and general question based on a wrong hypothesis, it would be more productive to provide a complete (and minimal example of the "failing" transformation -- then everyone here would tell exactly what is wrong.Dimitre Novatchev
BTW, we have been waiting 12 years for this page to become online -- hasn't yet.Dimitre Novatchev

2 Answers

3
votes

Using xmlns:something="..." declares an XML namespace. Such a namespace is merely a string, something that will help to attribute a unique meaning to element names like template or href, making sure multiple XML-based languages can be used in a single document without creating confusion as to its meaning.

Some of those namespaces are reserved for use by the W3C. The XSLT namespace is one of those. A proper XSLT processor will check if a stylesheet declares the correct namespace to make sure there can be no incorrect interpretation. The root element of the stylesheet should be in that XSLT namespace.

For an actual namespace value, you'd usually have a URI (and most often a URL) since that's normally a good unique identifier. However, this should never be used to actually resolve to any online resources during XML processing. Whereas HTTP URLs are normally treated in a case-insensitive manner and may make use of URL encoding for characters (e.g. space becomes %20), such resolution or equality of URLs is not checked in XML namespace processing. A namespace in XML is nothing but a string that's always checked in its exact form, casing and everything.

So if an XSLT processor complains that some resource at a URL cannot be found, then either it's doing something it shouldn't do, or the problem has nothing to do with namespace processing.

You're using Saxon, which most definitely isn't a processor that doesn't understand the concept of a namespace. Its father is Michael Kay who is also responsible for the XSLT 2.0 spec. But Saxon does support schema-aware XSLT processing. If a document specifies a schema location, then a processor using this for validation would actually use that location to get the schema. That's the difference with a namespace. DTDs and XML Schema locations can definitely result in network activity.

So I advise you to check if...

  • the XML uses a DTD with external definitions and whether those are available;
  • the XML specifies a schema location and whether that location can be reached;
  • the stylesheet makes use of a schema or some other external resource and whether that's available.

Once you've found the cause, look into the use of XML catalogs in conjunction with the processor. An XML catalog will allow you to use local resources if they can't be resolved from their URIs.

1
votes

Simple answer: The http://www.w3.org/1999/XSL/Transform isn't a URL, it's just a string. If W3C had decided, there's no reason it couldn't have been 'ThisIsAnXsltStylesheet'. By convention, they usually resemble URL's, but this isn't required.

So, the fact that there's nothing at that URL isn't relevant to why your stylesheet is failing, and certainly won't be the cause. Logically speaking, if that were the case, then nobody without an internet connection would ever be able to use XSLT, and w3c's servers would be seriously overworked.

I'd recommend adding the first few lines of your XSLT into your question; it might shed some light on where your problem really is.