in reply to Writing XML file according to schema with extracted text from string length

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

HTH,

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

Replies are listed 'Best First'.
Re^2: Writing XML file according to schema with extracted text from string length
by VikashParijat (Initiate) on Jan 09, 2009 at 07:23 UTC
    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
        Hi,

        Here is my code.

        use XML::Compile::Schema;

        use XML::LibXML;

        my $doc = XML::LibXML::Document->new('1.0', 'UTF-8');

        my $schema = XML::Compile::Schema->new('Example.xsd', ignore_unused_tags => 0);

        my $write = $schema->compile(WRITER => "RootTag");

        my $xml = $write->($doc, $hash);

        my $result = $doc->setDocumentElement($xml);

        Kindly help me..

        Thanks.