Author: tchemit Date: 2010-11-12 12:41:34 +0100 (Fri, 12 Nov 2010) New Revision: 1805 Url: http://nuiton.org/repositories/revision/i18n/1805 Log: introduce prepareFile method to be able to do things before scanning it Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/AbstractParserXmlMojo.java Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/AbstractParserXmlMojo.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/AbstractParserXmlMojo.java 2010-11-12 11:41:16 UTC (rev 1804) +++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/AbstractParserXmlMojo.java 2010-11-12 11:41:34 UTC (rev 1805) @@ -316,7 +316,6 @@ NamespaceContext ctx = new NamespaceContext() { public String getNamespaceURI(String prefix) { return XmlFileParser.this.namespaces.get(prefix); -// return getNamespaceForPrefix(prefix, doc); } @Override @@ -336,21 +335,38 @@ } } + /** + * To prepare the file (if any thing to be done before scanning it). + * + * @param file the incoming file + * @return the real file to process + * @throws IOException if any IO problem while preparing file + * @since 2.0 + */ + public File prepareFile(File file) throws IOException { + + // by default, do nothing + return file; + } + @Override public void parseFile(File file) throws IOException { + File fileToProcess = prepareFile(file); try { // Recherche des clés à partir d'un xpath - Document doc = builder.parse(file.getAbsolutePath()); + Document doc = builder.parse(fileToProcess.getAbsolutePath()); XPathExpression expression = xpath.compile(rules); NodeList list = (NodeList) expression.evaluate(doc, XPathConstants.NODESET); - getLog().info("Detected nodes [" + file + "] : " + list.getLength()); + if (getLog().isDebugEnabled()) { + getLog().debug("Detected nodes [" + file + "] : " + list.getLength()); + } for (int index = 0; index < list.getLength(); index++) { Node node = list.item(index); - parseLine(file, node.getTextContent()); + parseLine(fileToProcess, node.getTextContent()); } } catch (Exception e) { throw new ParserException(e);
participants (1)
-
tchemit@users.nuiton.org