VikashParijat has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I have a problem. I write an XML file against the schema using XML::Compile:: Schema by providing a hash.

This hash is created by me from the database tables. The length specified in the schema file is less than the length of the string actually extracted from the table fields. Thus, it conflicts and throws an error.

So, now I want to write XML file which read schema and if the length of the text is more it should extract as mentioned in the schema file and write to XML and should not throw an error.

Somebody, Kindly help me on this!!!!

Thanks.

  • Comment on Writing XML file according to schema with extracted text from string length

Replies are listed 'Best First'.
Re: Writing XML file according to schema with extracted text from string length
by planetscape (Chancellor) on Jan 09, 2009 at 07:07 UTC

    What approach have you tried, and what portion of that is not working for you?

    HTH,

    planetscape
      I used XML::COmpile::Schema module which takes hash containing the data and the schema file as an argument and writes the XML file according to the schema.

      Only what is not happening is that suppose the schema specifies string length of 6 for element <example> but my hash contains a 17 length text for that tag then it throws an error.

      What I want is that it should extract the first 6 characters from the 17 length and write as the value for the tag.

      Please help me out.

        And the code and data you have written are cleverly hidden ... where?

        HTH,

        planetscape
Re: Writing XML file according to schema with extracted text from string length
by Skeeve (Parson) on Jan 09, 2009 at 08:29 UTC

    I don't know anything about XML::Compile but from looking at the documentation, I guess it might be possible to define a hook that can process your data in such a way that it fits.


    s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
    +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e