From: <wol...@us...> - 2009-11-26 20:47:37
|
Revision: 10654 http://exist.svn.sourceforge.net/exist/?rev=10654&view=rev Author: wolfgang_m Date: 2009-11-26 20:47:22 +0000 (Thu, 26 Nov 2009) Log Message: ----------- [bugfix] bad module URI generated by ant task xqdoc:scan Port of rev 10653. Revision Links: -------------- http://exist.svn.sourceforge.net/exist/?rev=10653&view=rev Modified Paths: -------------- stable/eXist-1.4.x/extensions/xqdoc/ant-example.xml stable/eXist-1.4.x/extensions/xqdoc/src/org/exist/xqdoc/XQDocHelper.java stable/eXist-1.4.x/extensions/xqdoc/src/org/exist/xqdoc/ant/XQDocTask.java stable/eXist-1.4.x/extensions/xqdoc/src/org/exist/xqdoc/xquery/Scan.java Property Changed: ---------------- stable/eXist-1.4.x/extensions/modules/src/org/exist/xquery/modules/jfreechart/JFreeCharting.java Property changes on: stable/eXist-1.4.x/extensions/modules/src/org/exist/xquery/modules/jfreechart/JFreeCharting.java ___________________________________________________________________ Modified: svn:mergeinfo - /trunk/eXist/extensions/modules/src/org/exist/xquery/modules/jfreechart/JFreeCharting.java:10520-10526,10529-10532,10537,10539-10540,10551-10552,10576,10583-10586 + /trunk/eXist/extensions/modules/src/org/exist/xquery/modules/jfreechart/JFreeCharting.java:10520-10526,10529-10532,10537,10539-10540,10551-10552,10576,10583-10586,10589,10653 Modified: stable/eXist-1.4.x/extensions/xqdoc/ant-example.xml =================================================================== --- stable/eXist-1.4.x/extensions/xqdoc/ant-example.xml 2009-11-26 20:37:14 UTC (rev 10653) +++ stable/eXist-1.4.x/extensions/xqdoc/ant-example.xml 2009-11-26 20:47:22 UTC (rev 10654) @@ -35,4 +35,4 @@ </xqdoc:scan> </target> -</project> \ No newline at end of file +</project> Modified: stable/eXist-1.4.x/extensions/xqdoc/src/org/exist/xqdoc/XQDocHelper.java =================================================================== --- stable/eXist-1.4.x/extensions/xqdoc/src/org/exist/xqdoc/XQDocHelper.java 2009-11-26 20:37:14 UTC (rev 10653) +++ stable/eXist-1.4.x/extensions/xqdoc/src/org/exist/xqdoc/XQDocHelper.java 2009-11-26 20:47:22 UTC (rev 10654) @@ -17,8 +17,8 @@ controller.setEncodeURIs(false); } - public String scan(Source source) throws XQDocException, IOException { - XQDocPayload payload = controller.process(source.getReader(), source.getKey().toString()); + public String scan(Source source, String name) throws XQDocException, IOException { + XQDocPayload payload = controller.process(source.getReader(), name); return payload.getXQDocXML(); } } Modified: stable/eXist-1.4.x/extensions/xqdoc/src/org/exist/xqdoc/ant/XQDocTask.java =================================================================== --- stable/eXist-1.4.x/extensions/xqdoc/src/org/exist/xqdoc/ant/XQDocTask.java 2009-11-26 20:37:14 UTC (rev 10653) +++ stable/eXist-1.4.x/extensions/xqdoc/src/org/exist/xqdoc/ant/XQDocTask.java 2009-11-26 20:47:22 UTC (rev 10654) @@ -29,13 +29,14 @@ "import module namespace xdb=\"http://exist-db.org/xquery/xmldb\";\n" + "declare namespace xqdoc=\"http://www.xqdoc.org/1.0\"\n;" + "declare variable $uri external;\n" + + "declare variable $name external;\n" + "declare variable $collection external;\n" + "declare variable $data external;\n" + "let $xml :=\n" + - "if ($uri eq '') then\n" + - " xqdm:scan-data($data)\n" + + "if ($uri) then\n" + + " xqdm:scan(xs:anyURI($uri))\n" + "else\n" + - " xqdm:scan(xs:anyURI($uri))\n" + + " xqdm:scan($data, $name)\n" + "let $moduleURI := $xml//xqdoc:module/xqdoc:uri\n" + "let $docName := concat(util:hash($moduleURI, 'MD5'), '.xml')\n" + "return\n" + @@ -73,6 +74,7 @@ service.declareVariable("uri", ""); if (moduleURI != null) { service.declareVariable("uri", moduleURI); + service.declareVariable("data", ""); service.execute(source); } else { for(FileSet fileSet: fileSets) { @@ -87,6 +89,7 @@ log("Storing " + files[i] + " ...\n"); byte[] data = read(file); try { + service.declareVariable("name", file.getName()); service.declareVariable("data", data); service.execute(source); } catch (XMLDBException e) { Modified: stable/eXist-1.4.x/extensions/xqdoc/src/org/exist/xqdoc/xquery/Scan.java =================================================================== --- stable/eXist-1.4.x/extensions/xqdoc/src/org/exist/xqdoc/xquery/Scan.java 2009-11-26 20:37:14 UTC (rev 10653) +++ stable/eXist-1.4.x/extensions/xqdoc/src/org/exist/xqdoc/xquery/Scan.java 2009-11-26 20:47:22 UTC (rev 10654) @@ -41,15 +41,15 @@ "the function docs.") ), new FunctionSignature( - new QName("scan-data", XQDocModule.NAMESPACE_URI, XQDocModule.PREFIX), - "Scan and extract function documentation from an external XQuery function module according to the" + - "XQDoc specification. The single argument URI may either point to an XQuery module stored in the " + - "db (URI starts with xmldb:exist:...) or a module in the file system. A file system module is " + - "searched in the same way as if it were loaded through an \"import module\" statement. Static " + - "mappings defined in conf.xml are searched first.", + new QName("scan", XQDocModule.NAMESPACE_URI, XQDocModule.PREFIX), + "Scan and extract function documentation from an external XQuery function module according to the " + + "XQDoc specification. The two parameter version of the function expects to get the source code of " + + "the module in the first argument and a name for the module in the second.", new SequenceType[] { new FunctionParameterSequenceType("data", Type.BASE64_BINARY, Cardinality.EXACTLY_ONE, - "The base64 encoded source data of the module") + "The base64 encoded source data of the module"), + new FunctionParameterSequenceType("name", Type.STRING, Cardinality.EXACTLY_ONE, + "The name of the module") }, new FunctionReturnSequenceType(Type.NODE, Cardinality.ZERO_OR_MORE, "the function docs.") @@ -63,8 +63,10 @@ @Override public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { Source source = null; - if (isCalledAs("scan-data")) { + String name; + if (getArgumentCount() == 2) { byte[] data = ((Base64Binary) args[0].itemAt(0)).getBinaryData(); + name = args[1].getStringValue(); source = new BinarySource(data, true); } else { String uri = args[0].getStringValue(); @@ -87,6 +89,7 @@ "declares a wrong mime-type"); } source = new DBSource(context.getBroker(), (BinaryDocument) doc, false); + name = doc.getURI().toString(); } catch (URISyntaxException e) { throw new XPathException(this, "invalid module uri: " + uri + ": " + e.getMessage(), e); } catch (LockException e) { @@ -104,6 +107,7 @@ uri = location; try { source = SourceFactory.getSource(context.getBroker(), context.getModuleLoadPath(), uri, false); + name = source.getKey().toString(); } catch (IOException e) { throw new XPathException(this, "failed to read module " + uri, e); } catch (PermissionDeniedException e) { @@ -113,7 +117,7 @@ } try { XQDocHelper helper = new XQDocHelper(); - String xml = helper.scan(source); + String xml = helper.scan(source, name); NodeValue root = ModuleUtils.stringToXML(context, xml); if (root == null) return Sequence.EMPTY_SEQUENCE; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |