Package nokogiri.internals

Examples of nokogiri.internals.XmlDomParserContext


    @JRubyMethod(required = 2, visibility = Visibility.PRIVATE)
    public IRubyObject in_context(ThreadContext context,
                                  IRubyObject str,
                                  IRubyObject options) {
        RubyModule klass;
        XmlDomParserContext ctx;
        InputStream istream;
        XmlDocument document;

        IRubyObject d = document(context);
        Ruby runtime = context.getRuntime();
        if (d != null && d instanceof XmlDocument) {
            document = (XmlDocument)d;
        } else {
            return runtime.getNil();
        }

        if (document instanceof HtmlDocument) {
            klass = getNokogiriClass(runtime, "Nokogiri::HTML::Document");
            ctx = new HtmlDomParserContext(runtime, options);
            ((HtmlDomParserContext)ctx).enableDocumentFragment();
            istream = new ByteArrayInputStream((rubyStringToString(str)).getBytes());
        } else if (document instanceof XmlDocument) {
            klass = getNokogiriClass(runtime, "Nokogiri::XML::Document");
            ctx = new XmlDomParserContext(runtime, options);
            String input = rubyStringToString(str);
            istream = new ByteArrayInputStream(input.getBytes());
        } else {
            return runtime.getNil();
        }

        ctx.setInputSource(istream);
        XmlDocument doc = ctx.parse(context, klass, runtime.getNil());

        RubyArray documentErrors = getErrorArray(document);
        RubyArray docErrors = getErrorArray(doc);
        if (isErrorIncreased(documentErrors, docErrors)) {
            for (int i = 0; i < docErrors.getLength(); i++) {
View Full Code Here


    public static IRubyObject newFromData(ThreadContext context,
                                          IRubyObject klass,
                                          IRubyObject[] args) {
        Ruby ruby = context.getRuntime();
        Arity.checkArgumentCount(ruby, args, 4, 4);
        XmlDomParserContext ctx =
            new XmlDomParserContext(ruby, args[2], args[3]);
        ctx.setInputSource(context, args[0], args[1]);
        return ctx.parse(context, klass, args[1]);
    }
View Full Code Here

   
    @JRubyMethod(visibility=Visibility.PRIVATE)
    public IRubyObject validate_file(ThreadContext context, IRubyObject file) {
        Ruby ruby = context.getRuntime();

        XmlDomParserContext ctx = new XmlDomParserContext(ruby, RubyFixnum.newFixnum(ruby, 1L));
        ctx.setInputSource(context, file, context.getRuntime().getNil());
        XmlDocument xmlDocument = ctx.parse(context, getNokogiriClass(ruby, "Nokogiri::XML::Document"), ruby.getNil());
        return validate_document_or_file(context, xmlDocument);
    }
View Full Code Here

TOP

Related Classes of nokogiri.internals.XmlDomParserContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.