English 中文(简体)
氯乙烯
原标题:Xerces on Android
  • 时间:2010-04-16 09:14:09
  •  标签:
  • android

我在邮寄名录档案中发现了几处关于Xerces的参考资料,但我仍然不清楚,如果有可能使用Xerces succes in Anders。 请让我提供这一信息?

如果答案是肯定的,请让我谈谈如何使用Xerces而不是违约的XML教区。

事先感谢您的支持

kind regards Barbara

问题回答

Xerces 扩展核心图书馆javax,该编码导致problem 加入(由@Avi.提及)。

你们可以通过重新包装必要的课堂来解决这一问题,并采用JarJar等工具。 在Xerces-for-Android上做了这项工作,其中在包装上mf上放在“正常”Xerces包之上。

您可查;Androjena ;它把Jana港带到安乐平台,它使用安乐素的XML教区而不是Xerces。 希望这一帮助吧!

您—— 在你的项目中,你需要把——记分-图书馆的指挥线选择添加到dex工具上。 但是,你应该这样做,因为当javax/xml/parsers/DocumentBuilder.等舱(例如)IS最后得到SDK版本的支持时,你的申请可能会中断。 相反,你或许应当使用jar,用于将Xerces重新包装成具有独特包装名称的自成一体的图书馆。

请注意,如果你在分-图书馆办法中包含一包 j或ava,那么分之十的错误信息就是指:

你走的道路将最终导致疼痛、痛苦、悲痛和悲伤。

同一错误信息还表明,你利用Jar重新包装图书馆。

我发现,我无法与安乐公司一道工作,但我确实找到了为安roid岛工作的Xerces-for-Android。 以下是有关设置和一些实例守则的细节。 Good:

以下是我的工作:

  1. Create a validation utility.
  2. Get both the xml and xsd into file on the android OS and use the validation utility against it.
  3. Use Xerces-For-Android to do the validation.

安德罗确实支持我们可以使用的一些包裹,我根据以下网址建立了我的Xml验证效用:

我最初的沙箱试验与java相当顺利,然后我试图将其拖到Dalvik,发现我的法典没有发挥作用。 一些事情与Dalvik一样得到支持,因此我做了一些修改。

我发现甲型六氯环己烷和甲型六氯环己烷的参考,因此我修改了我的沙箱试验(以下斜体与甲型六氯环己烷合作,例如):

import java.io.File;

import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;

import org.w3c.dom.Document;

/**
 * A Utility to help with xml communication validation.
 */
public class XmlUtil {

    /**
     * Validation method. 
     * Base code/example from: http://docs.oracle.com/javase/1.5.0/docs/api/javax/xml/validation/package-summary.html
     * 
     * @param xmlFilePath The xml file we are trying to validate.
     * @param xmlSchemaFilePath The schema file we are using for the validation. This method assumes the schema file is valid.
     * @return True if valid, false if not valid or bad parse. 
     */
    public static boolean validate(String xmlFilePath, String xmlSchemaFilePath) {

        // parse an XML document into a DOM tree
        DocumentBuilder parser = null;
        Document document;

        // Try the validation, we assume that if there are any issues with the validation
        // process that the input is invalid.
        try {
            // validate the DOM tree
            parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
            document = parser.parse(new File(xmlFilePath));

            // create a SchemaFactory capable of understanding WXS schemas
            SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);

            // load a WXS schema, represented by a Schema instance
            Source schemaFile = new StreamSource(new File(xmlSchemaFilePath));
            Schema schema = factory.newSchema(schemaFile);

            // create a Validator instance, which can be used to validate an instance document
            Validator validator = schema.newValidator();
            validator.validate(new DOMSource(document));
        } catch (Exception e) {
            // Catches: SAXException, ParserConfigurationException, and IOException.
            return false;
        }     

        return true;
    }
}

上述代码必须修改部分,以便与 and的xerces合作()。 你们需要特别志愿人员协会来获得该项目,以下是一些书记:

download xerces-for-android
    download silk svn (for windows users) from http://www.sliksvn.com/en/download
        install silk svn (I did complete install)
        Once the install is complete, you should have svn in your system path.
        Test by typing "svn" from the command line.
        I went to my desktop then downloaded the xerces project by:
            svn checkout http://xerces-for-android.googlecode.com/svn/trunk/ xerces-for-android-read-only
        You should then have a new folder on your desktop called xerces-for-android-read-only

上文(三舍五入)将它直接并入我的快速检测来源。 如果你愿意这样做的话,你可以很快地用Ant(http://ant.apache.org/manual/using.html)。 我得以找到以下工作,以鉴定我的xml:

import java.io.File;
import java.io.IOException;

import mf.javax.xml.transform.Source;
import mf.javax.xml.transform.stream.StreamSource;
import mf.javax.xml.validation.Schema;
import mf.javax.xml.validation.SchemaFactory;
import mf.javax.xml.validation.Validator;
import mf.org.apache.xerces.jaxp.validation.XMLSchemaFactory;

import org.xml.sax.SAXException;

/**
 * A Utility to help with xml communication validation.
 */public class XmlUtil {

    /**
     * Validation method. 
     * 
     * @param xmlFilePath The xml file we are trying to validate.
     * @param xmlSchemaFilePath The schema file we are using for the validation. This method assumes the schema file is valid.
     * @return True if valid, false if not valid or bad parse or exception/error during parse. 
     */
    public static boolean validate(String xmlFilePath, String xmlSchemaFilePath) {

        // Try the validation, we assume that if there are any issues with the validation
        // process that the input is invalid.
        try {
            SchemaFactory  factory = new XMLSchemaFactory();
            Source schemaFile = new StreamSource(new File(xmlSchemaFilePath));
            Source xmlSource = new StreamSource(new File(xmlFilePath));
            Schema schema = factory.newSchema(schemaFile);
            Validator validator = schema.newValidator();
            validator.validate(xmlSource);
        } catch (SAXException e) {
            return false;
        } catch (IOException e) {
            return false;
        } catch (Exception e) {
            // Catches everything beyond: SAXException, and IOException.
            e.printStackTrace();
            return false;
        } catch (Error e) {
            // Needed this for debugging when I was having issues with my 1st set of code.
            e.printStackTrace();
            return false;
        }

        return true;
    }
}

www.un.org/Depts/DGACM/index_spanish.htm 一些附带说明:

为了建立档案,我对书面文件作了简单说明:

public static void createFileFromString(String fileText, String fileName) {
    try {
        File file = new File(fileName);
        BufferedWriter output = new BufferedWriter(new FileWriter(file));
        output.write(fileText);
        output.close();
    } catch ( IOException e ) {
       e.printStackTrace();
    }
}

我还需要写到我能够进入的一个领域,因此我使用了:

String path = this.getActivity().getPackageManager().getPackageInfo(getPackageName(), 0).applicationInfo.dataDir;   

略微 ha,它运作。 我确信,这样做的方法较为简明,但我对我的成功表示赞成,因为我没有发现任何很好的例子。

你可以在安乐斯使用Xerces。 简言之,将jar子 into入你的校正,并添加到我们的安康。 项目建成后,将把Xerces编成Anden/Dalvik编成代典,并装入你的APK。 我在我的项目上成功使用了这个词。





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...