validate xml

Discussion in 'Ruby' started by jney, Jun 10, 2008.

  1. jney

    jney Guest

    anyone knows how to validate an xml string a schema using with libxml-
    ruby?
    validate_schema method is only available for XML::Document but not for
    XML::Reader.
    regards.
     
    jney, Jun 10, 2008
    #1
    1. Advertising

  2. jney

    Tiago Macedo Guest

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    You can create a document from your string:

    xp = XML::parser.new
    xp.string = your_string
    xml_doc = xp.parse


    Tiago Macedo

    jney wrote:
    | anyone knows how to validate an xml string a schema using with libxml-
    | ruby?
    | validate_schema method is only available for XML::Document but not for
    | XML::Reader.
    | regards.
    |
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v2.0.9 (GNU/Linux)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

    iEYEARECAAYFAkh6zSUACgkQxFuRTtCTMvLnhwCeJtDOWw1tra3z9oBxH9Syo8HE
    MToAnixT8tQJyB/pAPQ7r8kcUalPGin5
    =bbEL
    -----END PGP SIGNATURE-----
     
    Tiago Macedo, Jul 14, 2008
    #2
    1. Advertising

  3. Jean-sébastien Jney wrote:
    > anyone knows how to validate an xml string a schema using with libxml-
    > ruby?
    > validate_schema method is only available for XML::Document but not for
    > XML::Reader.
    > regards.


    Hello,

    I saw your post searching some help for LibXML.

    I'm trying to validate via LibXML::XML::Schema like it's written in the
    official documentation:

    http://libxml.rubyforge.org/rdoc/classes/LibXML/XML/Schema.html

    """

    # parse schema as xml document
    schema_document = XML::Document.file('schema.rng')

    # prepare schema for validation
    schema = XML::Schema.document(schema_document)

    # parse xml document to be validated
    instance = XML::Document.file('instance.xml')

    # validate
    instance.validate_schema(schema)

    """


    ...but there is something wrong about installation because I can't use
    the validation method. I don't have it. I was looking around and I can't
    see the method anywhere.

    Do you have any idea??

    P.S. I'm using Leopard as SO and I haven't changed anything about
    libxml2.

    Thanks in advance,
    Raul.
    --
    Posted via http://www.ruby-forum.com/.
     
    Raul Martinez, Apr 20, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Leona
    Replies:
    9
    Views:
    2,061
    Henry S. Thompson
    Nov 1, 2004
  2. Edwin Dankert
    Replies:
    7
    Views:
    493
    Peter Flynn
    Oct 6, 2007
  3. Edwin Dankert
    Replies:
    0
    Views:
    421
    Edwin Dankert
    Jan 23, 2008
  4. Stefan
    Replies:
    3
    Views:
    2,071
    Martin Honnen
    Mar 29, 2008
  5. Andy B
    Replies:
    0
    Views:
    389
    Andy B
    Aug 7, 2008
Loading...

Share This Page