Return-Path:
Delivered-To: apmail-cocoon-cvs-archive@www.apache.org
Received: (qmail 31355 invoked from network); 19 May 2005 21:28:35 -0000
Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199)
by minotaur.apache.org with SMTP; 19 May 2005 21:28:35 -0000
Received: (qmail 5547 invoked by uid 500); 19 May 2005 21:16:03 -0000
Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org
Received: (qmail 5448 invoked by uid 500); 19 May 2005 21:16:02 -0000
Mailing-List: contact cvs-help@cocoon.apache.org; run by ezmlm
Precedence: bulk
Reply-To: dev@cocoon.apache.org
list-help:
list-unsubscribe:
List-Post:
List-Id:
Delivered-To: mailing list cvs@cocoon.apache.org
Received: (qmail 5408 invoked by uid 99); 19 May 2005 21:16:02 -0000
X-ASF-Spam-Status: No, hits=-9.8 required=10.0
tests=ALL_TRUSTED,NO_REAL_NAME
X-Spam-Check-By: apache.org
Received: from minotaur.apache.org (HELO minotaur.apache.org)
(209.237.227.194)
by apache.org (qpsmtpd/0.28) with SMTP; Thu, 19 May 2005 14:14:35 -0700
Received: (qmail 5071 invoked by uid 65534); 19 May 2005 21:06:48 -0000
Message-ID: <20050519210648.5070.qmail@minotaur.apache.org>
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Subject: svn commit: r170999 -
/cocoon/blocks/unsupported/repository/trunk/java/org/apache/cocoon/components/source/impl/XPathSourceInspector.java
Date: Thu, 19 May 2005 21:06:47 -0000
To: cvs@cocoon.apache.org
From: vgritsenko@apache.org
X-Mailer: svnmailer-1.0.0-dev
X-Virus-Checked: Checked
X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N
Author: vgritsenko
Date: Thu May 19 14:06:47 2005
New Revision: 170999
URL: http://svn.apache.org/viewcvs?rev=3D170999&view=3Drev
Log:
set input source system id
Modified:
cocoon/blocks/unsupported/repository/trunk/java/org/apache/cocoon/compo=
nents/source/impl/XPathSourceInspector.java
Modified: cocoon/blocks/unsupported/repository/trunk/java/org/apache/cocoon=
/components/source/impl/XPathSourceInspector.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/unsupported/repository/tru=
nk/java/org/apache/cocoon/components/source/impl/XPathSourceInspector.java?=
rev=3D170999&r1=3D170998&r2=3D170999&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- cocoon/blocks/unsupported/repository/trunk/java/org/apache/cocoon/compo=
nents/source/impl/XPathSourceInspector.java (original)
+++ cocoon/blocks/unsupported/repository/trunk/java/org/apache/cocoon/compo=
nents/source/impl/XPathSourceInspector.java Thu May 19 14:06:47 2005
@@ -1,12 +1,12 @@
/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *=20
+ * Copyright 1999-2005 The Apache Software Foundation.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *=20
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *=20
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -40,11 +40,12 @@
=20
/**
* This source inspector inspects XML files with a xpath expression.
- *=20
- * @version CVS $Id: XPathSourceInspector.java,v 1.8 2004/03/27 21:49:09 u=
nico Exp $
+ *
+ * @version $Id$
*/
-public class XPathSourceInspector extends AbstractLogEnabled=20
-implements SourceInspector, Serviceable, Parameterizable, ThreadSafe {
+public class XPathSourceInspector extends AbstractLogEnabled
+ implements SourceInspector, Serviceable,
+ Parameterizable, ThreadSafe {
=20
/**
* The default namespace uri of the property exposed by this SourceIns=
pector.
@@ -53,7 +54,7 @@
*
*/
public static final String DEFAULT_PROPERTY_NS =3D "http://apache.org/=
cocoon/inspector/xpath/1.0";
- =20
+
/**
* The default property name exposed by this SourceInspector.
*
@@ -61,46 +62,49 @@
*
*/
public static final String DEFAULT_PROPERTY_NAME =3D "result";
- =20
+
private String m_namespace;
private String m_propertyname;
private String m_extension;
private String m_xpath;
- =20
- private ServiceManager manager =3D null;
- =20
+
+ private ServiceManager manager;
+
+
public XPathSourceInspector() {
}
- =20
+
public void service(ServiceManager manager) {
this.manager =3D manager;
}
- =20
+
public void parameterize(Parameters params) throws ParameterException {
this.m_namespace =3D params.getParameter("namespace", DEFAULT_PROP=
ERTY_NS);
this.m_propertyname =3D params.getParameter("name", DEFAULT_PROPER=
TY_NAME);
this.m_extension =3D params.getParameter("extension", ".xml");
this.m_xpath =3D params.getParameter("xpath", "/*");
}
- =20
- public SourceProperty getSourceProperty(Source source, String namespac=
e, String name)=20
+
+ public SourceProperty getSourceProperty(Source source, String namespac=
e, String name)
throws SourceException {
=20
- if ((namespace.equals(m_namespace)) &&=20
- (name.equals(m_propertyname)) &&=20
+ if ((namespace.equals(m_namespace)) &&
+ (name.equals(m_propertyname)) &&
(source.getURI().endsWith(m_extension))) {
=20
DOMParser parser =3D null;
Document doc =3D null;
- try {=20
+ try {
parser =3D (DOMParser) manager.lookup(DOMParser.ROLE);
- doc =3D parser.parseDocument(new InputSource(source.getInp=
utStream()));
+ InputSource is =3D new InputSource(source.getInputStream()=
);
+ is.setSystemId(source.getURI());
+ doc =3D parser.parseDocument(is);
} catch (SAXException se) {
- this.getLogger().error(source.getURI() + " is not a valid =
XML file");
+ getLogger().error(source.getURI() + " is not a valid XML f=
ile");
} catch (IOException ioe) {
- this.getLogger().error("Could not read file", ioe);
+ getLogger().error("Could not read file", ioe);
} catch (ServiceException ce) {
- this.getLogger().error("Missing service dependency: DOMPar=
ser", ce);
+ getLogger().error("Missing service dependency: DOMParser",=
ce);
} finally {
if (parser !=3D null) {
this.manager.release(parser);
@@ -123,7 +127,7 @@
}
}
}
- }=20
+ }
return null;
}
=20
@@ -133,7 +137,7 @@
return new SourceProperty[]{property};
return null;
}
- =20
+
public boolean handlesProperty(String namespace, String name) {
return this.m_namespace.equals(namespace) && this.m_propertyname.e=
quals(name);
}
@@ -144,6 +148,5 @@
public SourceValidity getValidity(Source source) {
return NOPValidity.SHARED_INSTANCE;
}
- =20
-}
=20
+}