in reply to Re^4: XML::LibXML - parsing question!!
in thread XML::LibXML - parsing question!!

No luck...

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 '([0-9]{1,3}\.){3}[0-9] +{1,3}'. Element 'application_host_ip' [ST local, facet 'pattern']: The value ' +123.123.24.56' is not accepted by the pattern '([0-9]{1,3}\.){3}[0-9] +{1,3}'.

Just wondering.... if this could be a bug in XML::LibXML::Schema.... and would it be worthwhile submitting a bug report on CPAN.

Replies are listed 'Best First'.
Re^6: XML::LibXML - parsing question!!
by ikegami (Patriarch) on Dec 19, 2009 at 19:50 UTC

    I caved in and did your work and it validated fine for me, both with \d and the more correct [0-9]. I suppose I guessed incorrectly about the pieces you didn't show us. Now you know why I don't like guessing.

    Also check the XML with a hex editor. There might be non-printable characters or something in there.

      Well here goes....

      XML

      <?xml version="1.0" encoding="UTF-8"?> <instruction_request xmlns="http://www.finra.org/market_reg/admin_serv +er/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.finra.org/market_reg/admin_server/1 +.0 admin_server.xsd"> <request> <!-- The action to be performed => stop / start / reset --> <action_request> <action>START</action> <!-- Application instance information. --> <instance_information> <!-- Application name. --> <application_type> app_type </application_type> <!-- The instance name. --> <application_name> some_app </application_name> <!-- This defines the environment: QC / DEV / PROD -- +> <environment>QC</environment> <!-- This is the IP address of the application that is + --> <!-- being controlled in ASCII dotted-quad notation. + --> <application_host_ip>123.123.24.56</application_host_i +p> <!-- The hostname of the machine on which the machine +is exeucting. --> <application_host_name> somehost.finra.org </applicati +on_host_name> </instance_information> </action_request> </request> <request> <!-- The action to be performed => stop / start / reset --> <action_request> <action>STOP</action> <!-- Application instance information. --> <instance_information> <!-- Application name. --> <application_type> appname </application_type> <!-- The instance name. --> <application_name> app_instance </application_name> <!-- This defines the environment: QC / DEV / PROD -- +> <environment>QC</environment> <!-- This is the IP address of the application that is + --> <!-- being controlled in ASCII dotted-quad notation. + --> <application_host_ip>123.123.24.56</application_host_i +p> <!-- The hostname of the machine on which the machine +is exeucting. --> <application_host_name> somehost.finra.org </applicati +on_host_name> </instance_information> </action_request> </request> <request> <info_request> <action>GET_INFO</action> </info_request> </request> </instruction_request>

      XML Schema

      <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:admin_server="http://www.finra.org/market_reg/admin_server/1 +.0" targetNamespace="http://www.finra.org/market_reg/admin_server/1.0" elementFormDefault="qualified"> <xs:annotation> <xs:appinfo xml:lang="English">This schema defines the XML str +ucture that the admin server expects from the catalyst server.</xs:ap +pinfo> </xs:annotation> <xs:element name="instruction_request"> <xs:annotation> <xs:documentation>The root element. An instruction request + can contain 1 or more requests.</xs:documentation> </xs:annotation> <xs:complexType> <xs:sequence maxOccurs="1"> <xs:element name="request" type="admin_server:request_ +choice_type" maxOccurs="unbounded"> <xs:annotation> <xs:documentation>A request must outline: (1) The action to be taken. (2) The application on which action is to be taken. (This can be optio +nal if the action is to request information about all known applicati +on instances.).</xs:documentation> </xs:annotation> </xs:element> </xs:sequence> </xs:complexType> </xs:element> <xs:complexType name="request_choice_type"> <xs:choice> <xs:element name="action_request" type="admin_server:actio +n_request_type"> <xs:annotation> <xs:documentation>The list of actions that are to +be carried out by the server.</xs:documentation> </xs:annotation> </xs:element> <xs:element name="info_request" type="admin_server:info_re +quest_type"> <xs:annotation> <xs:documentation>The list of information requests +. These are used to request information for specific application inst +ances if specified. If application instances are not specified, the s +erver replies back with information about all instances about which i +t has information.</xs:documentation> </xs:annotation> </xs:element> </xs:choice> </xs:complexType> <xs:complexType name="instance_info_type"> <xs:all> <xs:element name="application_type"> <xs:annotation> <xs:documentation>The type of application. </xs:documentation> </xs:annotation> <xs:simpleType> <xs:restriction base="xs:string"> <xs:minLength value="1"/> <xs:maxLength value="1024"/> </xs:restriction> </xs:simpleType> </xs:element> <xs:element name="application_name"> <xs:annotation> <xs:documentation>The name of the application.</xs +:documentation> </xs:annotation> <xs:simpleType> <xs:restriction base="xs:string"> <xs:minLength value="1"/> <xs:maxLength value="1024"/> </xs:restriction> </xs:simpleType> </xs:element> <xs:element name="environment"> <xs:annotation> <xs:documentation>The environment in which the app +lication is executing. The environment types are enumerated. For instance: QC.</xs:documentation> </xs:annotation> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="DEV"> <xs:annotation> <xs:documentation>Development environm +ent.</xs:documentation> </xs:annotation> </xs:enumeration> <xs:enumeration value="QC"> <xs:annotation> <xs:documentation>QC environment.</xs: +documentation> </xs:annotation> </xs:enumeration> <xs:enumeration value="PROD"> <xs:annotation> <xs:documentation>Production environme +nt.</xs:documentation> </xs:annotation> </xs:enumeration> <xs:minLength value="1"/> <xs:maxLength value="4"/> <xs:whiteSpace value="collapse"/> </xs:restriction> </xs:simpleType> </xs:element> <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:maxLength value="15"/> <xs:minLength value="7"/> <xs:whiteSpace value="collapse"/> <xs:pattern value="([0-9]{1,3}\.){3}[0-9]{1,3} +"/> </xs:restriction> </xs:simpleType> </xs:element> <xs:element minOccurs="0" name="application_host_name"> <xs:annotation> <xs:documentation>The hostname of the machine on w +hich the application is executing.</xs:documentation> </xs:annotation> <xs:simpleType> <xs:restriction base="xs:string"> <xs:minLength value="1"/> <xs:maxLength value="1024"/> <xs:whiteSpace value="collapse"/> </xs:restriction> </xs:simpleType> </xs:element> </xs:all> </xs:complexType> <xs:complexType name="action_request_type"> <xs:sequence> <xs:element name="action"> <xs:annotation> <xs:documentation>The action to be taken. The list + of valid actions are enumerated.</xs:documentation> </xs:annotation> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="START"/> <xs:enumeration value="STOP"/> <xs:enumeration value="RESTART"/> </xs:restriction> </xs:simpleType> </xs:element> <xs:element name="instance_information" type="admin_server +:instance_info_type"> <xs:annotation> <xs:documentation>The unique application specifica +tion on which the action is to be taken.</xs:documentation> </xs:annotation> </xs:element> </xs:sequence> </xs:complexType> <xs:complexType name="info_request_type"> <xs:sequence> <xs:element maxOccurs="1" name="action"> <xs:annotation> <xs:documentation>The list of actions to be taken. + In these instance, these are read_only actions. The list of actions +are enumerated.</xs:documentation> </xs:annotation> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="GET_INFO"/> </xs:restriction> </xs:simpleType> </xs:element> <xs:element minOccurs="0" name="instance_information" type="admin_server:instance_info_type"> <xs:annotation> <xs:documentation>This is optional in this case. I +f specified, the info is returned about the said instances.</xs:docum +entation> </xs:annotation> </xs:element> </xs:sequence> </xs:complexType> </xs:schema>

        Still no error. I'm stuck on XML::LibXML 1.66 on this machine, but that shouldn't matter. libxml2 2.6.32 for the backend
        >perl -MXML::LibXML -le"print for $XML::LibXML::VERSION, XML::LibXML:: +LIBXML_DOTTED_VERSION" 1.66 2.6.32

        No problems on this machine either

        $ perl -MXML::LibXML -le'print for $XML::LibXML::VERSION, XML::LibXML: +:LIBXML_DOTTED_VERSION' 1.70 2.6.32

        Same backend, so this was expected.

      Thx Ikegami..... but I checked the schema in vim.... looks pretty plain text to me.... I also opened it in 0xED (Im on a mac but its a hex editor.... looks good...

      Am investigating the issue... now I have never done this before but by providing a working example, would it be a good idea to post it to CPAN authors who have written this module? There aren't many examples out there for this module on CPAN. Will prolly help newbies like me.

Re^6: XML::LibXML - parsing question!!
by ikegami (Patriarch) on Dec 19, 2009 at 19:43 UTC
    I could do some testing, but neither your code nor your schema are usable.