Hmm I've been trying to validate the xml with my schema and my schema validation works perfectly in my xml editor (I'm using Oxygen XML Editor... not that it matters).

The validation fails when using XML::LibXML::Schema.

#---------------------------------------------------------- # Validate against XML schema. #---------------------------------------------------------- my $xml_schema = XML::LibXML::Schema->new( location => '/Users/dattanik/Programs/XML/admin_server.xsd' ); eval { $xml_schema->validate($dom); }; if ($@) { print "Looks like schema validation has failed. \n"; print "$@", "\n"; } else { print "XML Schema validation succeeded.\n"; }

I have a primitive facet for validating IP addresses...(\d{1,3}\.){3}\d{1,3} that's embedded in my XML Schema. I am also collapsing the embedded spaces in the application_host_ip element.

Nothing special here but it fails there when validating thru XML::LibXML::Schema.... the validation of the exact same XML document is successful using my schema. My relevant schema code is:

<xs:element name="application_host_ip"> <xs:annotation> <xs:documentation>The IP address of the host on wh +ich the application is executing.</xs:documentation> </xs:annotation> <xs:simpleType> <xs:restriction base="xs:string"> <xs:pattern value="(\d{1,3}\.){3}\d{1,3}"> <xs:annotation> <xs:documentation>This regular express +ion does a rudimentary check on the IP address.</xs:documentation> </xs:annotation> </xs:pattern> <xs:maxLength value="15"/> <xs:minLength value="7"/> <xs:whiteSpace value="collapse"/> </xs:restriction> </xs:simpleType> </xs:element>

Now I checked the support docs in XML::LibXML::Schema but it does not seem to provide any additional info besides the class interface.

The relevant output from STDOUT is printed...

Looks like schema validation has failed Element 'application_host_ip' [ST local, facet 'pattern']: The value ' +123.123.24.56' is not accepted by the pattern '(\d{1,3}\.){3}\d{1,3}' +. Element 'application_host_ip' [ST local, facet 'pattern']: The value ' +123.123.24.56' is not accepted by the pattern '(\d{1,3}\.){3}\d{1,3}' +.

I am doing all this as part of my pet project to monitor a myriad of applications running across my production network. These guys have log4j writers and currently the maintenance folks are individually logging into those boxes via ssh and running standard maintenance procedures. I am automating this process by writing a POE server that listens on these log4j and presents status info to a web client. The web user agent can then send requests in standard XML format that is interpreted by the server and it does the maintenance tasks... much more reliable. This is the last part :)....


In reply to Re^3: XML::LibXML - parsing question!! by MarkovChain
in thread XML::LibXML - parsing question!! by MarkovChain

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.