perl libxml writing xliff in strings.xml



I'm having difficulty writing to a strings.xml file that contains an XLIFF element using LibXML. Note that I'm trying to write a value that already exists (had no problem parsing the node while reading). I also need to use appendWellBalancedChunk as I write HTML elements sometimes.



#!/usr/bin/env perl

#
# Create a simple XML document
#

use strict;
use warnings;
use XML::LibXML;

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

my $root = $doc->createElement("resources");
my $tag = $doc->createElement("string");
$tag->setAttribute('name'=>'no_messages');
my $string = '<xliff:g id="MILLISECONDS">%s</xliff:g>ms';
$tag->appendWellBalancedChunk($string);
$root->appendChild($tag);

$doc->setDocumentElement($root);
print $doc->toString();


When I run this, I get the following:



$ perl xliff.pl
namespace error : Namespace prefix xliff on g is not defined
<xliff:g id="MILLISECONDS">%s</xliff:g>ms
^


Thanks


No comments:

Post a Comment