Как получить доступ к XML-файл из .jar для выполнения JAR из PHP-функции shell_exec

банку с сервера apache с php.
Я использую shell_exec и отдаю ей свой файл jar.

Но из-за того, что я анализирую XML-файл на своем Java-классе, у меня проблема. Джар не может получить доступ к XML.

файлы

SampleSax.java

package phpJavaPack;

import java.io.IOException;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.InputSource;
import org.xml.sax.SAXException;public class SampleSAX {

public static void main(String[] args) throws IOException, SAXException, ParserConfigurationException {
/*int i=0;
MyBufferedReaderWriter f = new MyBufferedReaderWriter();
f.openRFile("dblp.xml");
String sLine="";
while ((i<10) && (sLine=f.readLine()) != null) {
System.out.println(sLine);
i++;
}*/

int i=0;
while(i<args.length){

System.out.println("Argument's: " + args[0]);
System.setProperty("entityExpansionLimit", "1000000");

SAXParserFactory spfac = SAXParserFactory.newInstance();
spfac.setNamespaceAware(true);

SAXParser saxparser = spfac.newSAXParser();MyHandler handler = new MyHandler(args[i]);InputSource is = new InputSource("dblpmini.xml");
is.setEncoding("ISO-8859-1");
System.out.println("Please wait...");
saxparser.parse(is, handler);

System.out.println("---->" + handler.getprofessorsPublications());

i++;
}

//System.out.println("#####################################################################################################");
//System.out.println("List of George A. Vouros: " + handler.getprofessorsPublicationsValue("George A. Vouros"));//System.out.println(handler.getProfessors());

//handler.createHtmlPage();//emfanizei mia html selida me ta apotelesmata
}
}

MyHandler.java

package phpJavaPack;

import java.util.ArrayList;
import java.util.Hashtable;

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

public class MyHandler extends DefaultHandler {

private Publication publication;
protected Hashtable<String, ArrayList<Publication>> professorsPublications = new Hashtable<String, ArrayList<Publication>>();
private String temp ;
private ArrayList<Publication> al;

//private EntryLd entry = new EntryLd();

//       public MyHandler() {
//         super();
//
//         String[] namesTable = entry.getNamesInput();
//
//
//         for (String name: namesTable) {
//
//             al = new ArrayList<Publication>();
//             professorsPublications.put(name, al);
//         }
//
//         System.out.println("HashTable: " + professorsPublications);
//       }

public MyHandler(String authorForSearch){
super();
String name = authorForSearch;

al = new ArrayList<Publication>();
professorsPublications.put(name, al);

System.out.println("HashTable: " + professorsPublications);
}

public Hashtable<String, ArrayList<Publication>> getprofessorsPublications() {

return professorsPublications;
}

public ArrayList<Publication> getprofessorsPublicationsValue(String author) {

return professorsPublications.get(author);
}public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
{
temp = "";
if (qName.equalsIgnoreCase("article") || qName.equalsIgnoreCase("inproceedings")
|| qName.equalsIgnoreCase("proceedings") || qName.equalsIgnoreCase("book")
|| qName.equalsIgnoreCase("incollection") || qName.equalsIgnoreCase("phdthesis")
|| qName.equalsIgnoreCase("mastersthesis") || qName.equalsIgnoreCase("www")) {
publication = new Publication();
}
}

public void characters(char[] ch, int start, int length) {
temp = new String(ch, start, length);
System.out.println("----->>>" + temp);
//System.out.print(" <--- My temp's start: " + temp + " :My temp's end --> ");
}public void endElement(String uri, String localName, String qName) throws SAXException
{
if (qName.equalsIgnoreCase("article") || qName.equalsIgnoreCase("inproceedings")
|| qName.equalsIgnoreCase("proceedings") || qName.equalsIgnoreCase("book")
|| qName.equalsIgnoreCase("incollection") || qName.equalsIgnoreCase("phdthesis")
|| qName.equalsIgnoreCase("mastersthesis") || qName.equalsIgnoreCase("www"))
{
for(int i=0; i<publication.getAuthors().size(); i++) {
String authorName = publication.getAuthors().get(i);
if(this.professorsPublications.containsKey(authorName)) {
this.publication.setType(localName);
this.professorsPublications.get(authorName).add(publication);
}
}
}
if(qName.equalsIgnoreCase("author")) {
publication.addAuthor(temp);
}
else if(qName.equalsIgnoreCase("title")) {
publication.setTitle(temp);
}
else if(qName.equalsIgnoreCase("year")) {
publication.setYear(Short.parseShort(temp));
}
else if(qName.equalsIgnoreCase("booktitle")) {
publication.setBooktitle(temp);
}

//String xl = publication.toString();
//System.out.println(xl);
}

}

Как дать правильный XML на работающей банке?

Thnx

0

Решение

увидеть PHP exec () команда: как указать рабочий каталог? — скорее всего proc_open предложение / пример есть лучший

см. другие предложения в этой теме, например, chdir

0

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector