Revision: 7102
          
http://languagetool.svn.sourceforge.net/languagetool/?rev=7102&view=rev
Author:   milek_pl
Date:     2012-05-29 22:14:18 +0000 (Tue, 29 May 2012)
Log Message:
-----------
add "url" info to xml api, document in changes

Modified Paths:
--------------
    trunk/JLanguageTool/CHANGES.txt
    trunk/JLanguageTool/src/java/org/languagetool/tools/StringTools.java
    trunk/JLanguageTool/src/resource/api-output.dtd
    trunk/JLanguageTool/src/test/org/languagetool/MainTest.java

Modified: trunk/JLanguageTool/CHANGES.txt
===================================================================
--- trunk/JLanguageTool/CHANGES.txt     2012-05-29 22:12:10 UTC (rev 7101)
+++ trunk/JLanguageTool/CHANGES.txt     2012-05-29 22:14:18 UTC (rev 7102)
@@ -41,9 +41,11 @@
     author Bertilo Wennergren, and to Lernu.net also with
     permission of the lernu team.
 
- -LibreOffice: if a LanguageTool rule has an URL with more information, the
+ -If a LanguageTool rule has an URL with more information, the
   grammar checking dialog in LibreOffice will now offer a "More..." link
-  to that URL. This makes possible to have external documentation about rules.
+  to that URL in LibreOffice, as well as on the command line as "More info:", 
+  and as "url" attribute of the <error> element in the XML API format. 
+  This makes possible to have external documentation about rules.
 
  -LibreOffice / OpenOffice integration: SingletonFactory now implements
   XServiceInfo (Stephan Bergmann) - Sourceforge bug #3526635
@@ -69,7 +71,7 @@
  -Overlapping rule matches are filtered now so that only the first match per 
<rulegroup> is kept
  
  -In the profiling rules' mode on the command-line, you can now enable 
-  and disable rules. 
+  and disable rules.  
 
 
 1.7 (2012-03-25)

Modified: trunk/JLanguageTool/src/java/org/languagetool/tools/StringTools.java
===================================================================
--- trunk/JLanguageTool/src/java/org/languagetool/tools/StringTools.java        
2012-05-29 22:12:10 UTC (rev 7101)
+++ trunk/JLanguageTool/src/java/org/languagetool/tools/StringTools.java        
2012-05-29 22:14:18 UTC (rev 7102)
@@ -358,6 +358,9 @@
       xml.append(" context=\"" + StringTools.escapeXML(context) + "\"");
       xml.append(" contextoffset=\"" + contextOffset + "\"");
       xml.append(" errorlength=\"" + (match.getToPos() - match.getFromPos()) + 
"\"");
+      if (match.getRule().getUrl() != null) {
+         xml.append(" url=\"" + match.getRule().getUrl().toString() + "\"");
+      }
       xml.append("/>\n");
     }
     if (xmlMode == XmlPrintMode.END_XML || xmlMode == XmlPrintMode.NORMAL_XML) 
{

Modified: trunk/JLanguageTool/src/resource/api-output.dtd
===================================================================
--- trunk/JLanguageTool/src/resource/api-output.dtd     2012-05-29 22:12:10 UTC 
(rev 7101)
+++ trunk/JLanguageTool/src/resource/api-output.dtd     2012-05-29 22:14:18 UTC 
(rev 7102)
@@ -56,6 +56,9 @@
 -->
 <!ATTLIST error errorlength CDATA #REQUIRED>
 
+<!-- The url with additional information that may be given --> 
+<!ATTLIST error url CDATA #IMPLIED>
+
 <!-- Note that the XML output may contain XML comments with
 additional information like timing and debugging information.
 These can be ignored. -->

Modified: trunk/JLanguageTool/src/test/org/languagetool/MainTest.java
===================================================================
--- trunk/JLanguageTool/src/test/org/languagetool/MainTest.java 2012-05-29 
22:12:10 UTC (rev 7101)
+++ trunk/JLanguageTool/src/test/org/languagetool/MainTest.java 2012-05-29 
22:14:18 UTC (rev 7102)
@@ -262,6 +262,32 @@
     assertTrue(output.indexOf("<error fromy=\"0\" fromx=\"8\" toy=\"0\" 
tox=\"11\" ruleId=\"EN_A_VS_AN\" msg=\"Use 'a' instead of 'an' if the following 
word doesn't start with a vowel sound, e.g. 'a sentence', 'a university'\" 
replacements=\"a\" context=\"This is an test. \" contextoffset=\"8\" 
errorlength=\"2\"/>") != -1);
   }
   
+  public void testGermanFileIwithURL() throws URISyntaxException, IOException, 
ParserConfigurationException, SAXException {
+
+           File input = createTempFile();
+           // Populate the file with data.
+           PrintWriter w = new PrintWriter(new OutputStreamWriter(new 
FileOutputStream(input), "UTF-8"));
+           w.println("Ward ihr zufrieden damit?");
+           w.close();
+
+           String[] args = new String[] {"-l", "de", "--api", 
input.getAbsolutePath()};
+
+           Main.main(args);
+           String output = new String(this.out.toByteArray());
+           assertTrue(output.indexOf("<?xml version=\"1.0\" 
encoding=\"UTF-8\"?>") == 0);
+           assertTrue(output.indexOf("ruleId=\"WARD_VS_WART\" subId=\"1\"") != 
-1);
+           //check URL part
+           
assertTrue(output.indexOf("url=\"http://www.korrekturen.de/beliebte_fehler/ward.shtml\"";)
 != -1);
+           
+           //now check in normal mode and check for URL
+           
+           args = new String[] {"-l", "de", input.getAbsolutePath()};
+           Main.main(args);
+           output = new String(this.out.toByteArray());
+           assertTrue(output.indexOf("More info: 
http://www.korrekturen.de/beliebte_fehler/ward.shtml";) != -1);
+         }
+ 
+  
   public void testPolishFileAPI() throws URISyntaxException, IOException, 
ParserConfigurationException, SAXException {
     File input = createTempFile();
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Languagetool-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/languagetool-cvs

Reply via email to