RE: [xsl] Can't use any of the xdt functions! Grrrr

Subject: RE: [xsl] Can't use any of the xdt functions! Grrrr
From: Pieter Reint Siegers Kort <pieter.siegers@xxxxxxxxxxx>
Date: Fri, 18 Mar 2005 18:30:05 -0600
> Or try this query:

java net.sf.saxon.Query -t
"{<axmlns:j='java:net.sf.saxon.om.NamespaceConstant'>{j:XDT()}</a>}" 

OK. Results:

Saxonb8-1:

C:\>java net.sf.saxon.Query -t "{<a
xmlns:j='java:net.sf.saxon.om.NamespaceConstant'>{j:X
DT()}</a>}"
Saxon 8.1 from Saxonica
Java version 1.4.2_04
Compiling query from {<a
xmlns:j='java:net.sf.saxon.om.NamespaceConstant'>{j:XDT()}</a>}
Compilation time: 125 milliseconds
<?xml version="1.0" encoding="UTF-8"?>
<a
xmlns:j="java:net.sf.saxon.om.NamespaceConstant">http://www.w3.org/2004/07/x
path-datatypes</a>Execution time: 62 mill
iseconds


Saxonb8-2:

C:\>java net.sf.saxon.Query -t "{<a
xmlns:j='java:net.sf.saxon.om.NamespaceConstant'>{j:X
DT()}</a>}"
Exception in thread "main" java.lang.NoClassDefFoundError:
org/w3c/dom/TypeInfo
        at java.lang.ClassLoader.defineClass0(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$100(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
        at java.lang.ClassLoader.defineClass0(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$100(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
        at java.lang.ClassLoader.defineClass0(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$100(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
        at net.sf.saxon.type.Type.<clinit>(Type.java:72)
        at
net.sf.saxon.functions.VendorFunctionLibrary.init(VendorFunctionLibrary.java
:57)
        at
net.sf.saxon.functions.VendorFunctionLibrary.<init>(VendorFunctionLibrary.ja
va:25)
        at
net.sf.saxon.Configuration.getVendorFunctionLibrary(Configuration.java:304)
        at
net.sf.saxon.query.StaticQueryContext.reset(StaticQueryContext.java:98)
        at
net.sf.saxon.query.StaticQueryContext.<init>(StaticQueryContext.java:68)
        at net.sf.saxon.Query.doMain(Query.java:92)
        at net.sf.saxon.Query.main(Query.java:75)


Saxonb8-3:

C:\>java net.sf.saxon.Query -t "{<a
xmlns:j='java:net.sf.saxon.om.NamespaceConstant'>{j:X
DT()}</a>}"
Saxon 8.3 from Saxonica
Java version 1.4.2_04
Compiling query from {<a
xmlns:j='java:net.sf.saxon.om.NamespaceConstant'>{j:XDT()}</a>}
Compilation time: 250 milliseconds
<?xml version="1.0" encoding="UTF-8"?>
<a
xmlns:j="java:net.sf.saxon.om.NamespaceConstant">http://www.w3.org/2005/02/x
path-datatypes</a>Execution time: 47 mill
iseconds


What causes the 8-2 build to err?

Cheers,
<prs/>

-----Original Message-----
From: Michael Kay [mailto:mike@xxxxxxxxxxxx] 
Sent: Viernes, 18 de Marzo de 2005 11:41 a.m.
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] Can't use any of the xdt functions! Grrrr

 
> I assume, that "xs:dayTimeDuration" is typo or from an older version 
> of the spec and now should be "xsd:dayTimeDuration"?

It should be xdt:....
> 
> Anyway, I've tried countless variations of the namespace (where do I 
> get the 'real' xdt namespace used by saxon???

W3C change the namespace each time a new working draft comes out, and Saxon
follows suit. So it depends which version you're using. For 8.3 it's
http://www.w3.org/2005/02/xpath-datatypes

The simplest way to get a 100% reliable answer is to look in the source code
for net.sf.saxon.om.NamespaceConstant.

Or try this query:

java net.sf.saxon.Query -t "{<a
xmlns:j='java:net.sf.saxon.om.NamespaceConstant'>{j:XDT()}</a>}"

Michael Kay
http://www.saxonica.com/

> 
> ---  here's one of the many iterations of stylesheet I've used 
> ---------
> 
> <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> xmlns:xs="http://www.w3.org/2001/XMLSchema";
> xmlns:fn="http://www.w3.org/2004/07/xpath-functions";
> xmlns:xdt="http://www.w3.org/2004/07/xpath-datatypes";
> xmlns:rs="http://java.sun.com/xml/ns/jdbc";>
> 	<xsl:output method="html" omit-xml-declaration="yes"/>
> 	<xsl:template match="/">
> 		<xsl:value-of select=" (current-date() +
> xdt:yearMonthDuration('P1Y')) +  xdt:dayTimeDuration('P1D')"/>
> 	</xsl:template>
> </xsl:stylesheet>
> 
> 
> 
> ---------------- Here's the stack trace-------------------
> 
> javax.xml.transform.TransformerException: No function found matching 
> xdt:yearMonthDuration with one argument
>     at
> net.sf.saxon.TransformerHandlerImpl.endDocument(TransformerHan
> dlerImpl.java:121)
>     at
> org.apache.xerces.parsers.AbstractSAXParser.endDocument(Unknow
> n Source)
>     at
> org.apache.xerces.impl.XMLDocumentScannerImpl.endEntity(Unknow
> n Source)
>     at
> org.apache.xerces.impl.XMLEntityManager.endEntity(Unknown Source)
>     at org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source)
>     at
> org.apache.xerces.impl.XMLEntityScanner.skipSpaces(Unknown Source)
>     at
> org.apache.xerces.impl.XMLDocumentScannerImpl$TrailingMiscDisp
> atcher.dispatch(Unknown
> Source)
>     at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocu
> ment(Unknown
> Source)
>     at
> org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>     at
> org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>     at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
> 
> 
> 
> --------------------------------------------------------
> 
> Ideas??? Thanks!

Current Thread