i have given an xsd file, an Perl Enviroment and can only use XML::LibXML XML::SAX XML::Compile
Relevant Part from xsd is
<complexType name="property">
<attribute type="propertyvalue" name="name" use="required"/>
<attribute type="string" name="value" use="required"/>
</complexType>
<simpleType name="propertyvalue">
<restriction base="string">
<enumeration value="propertya"/>
<enumeration value="propertyb"/>
[....some more values...]
</restriction>
</simpleType>
I've got to write multiple propertys for every value. As up to now, i worked with XML::Compile::Schema
$schema->template('PERL', $type);
my $doc = XML::LibXML::Document->new('1.0', 'UTF-8');
my $write = $schema->compile(WRITER => $type, use_default_namespace => 1);
my %hash;
$hash = {
properties =>
{
version => 42,
property =>
[ {name => "propertya",
value => "example",
}, ],
}
};
my $xml= $write->($doc, $hash);
$doc->setDocumentElement($xml);
My problem by now is, i cant see a way how i can add more than one property tag with somesing like
@properties =("propertya","propertyb",[.and so on.]);
foreach my $pname (@properties){
$hash = {
properties =>
{
version => 42,
property =>
[ {name => $pname;
value => "example",
}, ],
}
};
my $xml= $write->($doc, $hash);
$doc->setDocumentElement($xml);
}
without overwriting everything or getting Messages that other parts of the file are missing. Is there anyway to do this, and is there a way to attach tags lateron after executing my $xml = $write->($doc, $hash); ?
No comments:
Post a Comment