Changeset 13650
- Timestamp:
- 2007-01-17T11:14:23+13:00 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl-documentation/shared/ExternalRef.java
r13632 r13650 1 1 import java.io.InputStream; 2 2 import java.io.FileInputStream; 3 import java.io.File; 3 4 4 5 import org.w3c.dom.Document; … … 12 13 13 14 public class ExternalRef{ 14 15 public ExternalRef(){} 15 private String basePath; 16 public ExternalRef(){ 17 } 16 18 17 19 public String getRef(String file, String lang, String targettype, String id){ 18 20 getPath(); 19 21 try{ 20 String tfile = file+"_"+lang+".xml";21 String path =tfile;22 String tfile = file+"_"+lang+".xml"; 23 String path = basePath + "/xml-source/" + lang + "/" + tfile; 22 24 23 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();24 25 26 25 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 26 DocumentBuilder domBuilder = factory.newDocumentBuilder(); 27 InputStream is = new FileInputStream(path); 28 Document doc = domBuilder.parse(is); 27 29 28 30 NodeList list = doc.getElementsByTagName(targettype); … … 42 44 } 43 45 } 46 47 private void getPath(){ 48 basePath = System.getProperty("user.dir"); 49 50 System.err.println(basePath); 51 52 //find where is the manuals directory 53 File tempfile = new File(basePath); 54 String parentPath = tempfile.getParent(); 55 56 boolean find = false; 57 while(!find){ 58 System.err.println(parentPath); 59 File tempfile2 = new File(parentPath+"/manuals"); 60 if(tempfile2.exists() && tempfile2.isDirectory()){ 61 basePath = parentPath+"/manuals"; 62 find = true; 63 } 64 else if(parentPath.endsWith("manuals")){ 65 //if the shared directory is inside the manual directory 66 basePath = parentPath; 67 find = true; 68 } 69 if(!find){ 70 tempfile = new File(parentPath); 71 parentPath = tempfile.getParent(); 72 } 73 } 74 } 44 75 }
Note:
See TracChangeset
for help on using the changeset viewer.