6 my $LOCAL_XML = "./last2order.xml.tmp";
7 my $LOCAL_DTD = "./last2order.dtd";
10 <!ELEMENT last2order_tbl (last2order*) >
12 <!ELEMENT last2order EMPTY>
14 front_video CDATA "EMPTY"
15 front_sub_video CDATA "EMPTY"
16 front_audio CDATA "EMPTY"
17 rear_video CDATA "EMPTY"
18 rear_audio CDATA "EMPTY"
19 ordername CDATA #REQUIRED
24 print STDERR "USAGE:$0 *.xml *.cfo\n";
28 my $ret=system("which xmllint > /dev/null");
30 die("xmllint is not installed \n");
38 my $inXmlFile= $ARGV[0];
39 my $outCfgXmlFile= $ARGV[1];
44 die("$inXmlFile not found");
48 system("cp $inXmlFile $LOCAL_XML");
50 open FOUT,'>',$LOCAL_DTD or die("can't open $LOCAL_DTD");
54 $ret=system("xmllint --noout --valid $LOCAL_XML ");
56 die("$inXmlFile is NOT VAILD");
59 my $xml = XML::XPath->new(filename=>$LOCAL_XML);
61 my $last2order_tbl = $xml->find('/last2order_tbl/last2order');
63 my @nodelist = $last2order_tbl->get_nodelist;
64 my $numOfElement = @nodelist;
66 printf("num of element :$numOfElement\n");
69 open FOUT,'+>',$outCfgXmlFile or die("can't open $outCfgXmlFile");
72 $writeValue = pack("A4","CTOO"); print FOUT $writeValue;
73 $writeValue = pack("L",$numOfElement); print FOUT $writeValue;
75 foreach my $last2order( @nodelist ) {
76 $writeValue = $last2order->findvalue('@front_video');
77 printf("FV:$writeValue ");
78 $writeValue = pack("a128",$writeValue); print FOUT $writeValue;
80 $writeValue = $last2order->findvalue('@front_sub_video');
81 printf("FSV:$writeValue ");
82 $writeValue = pack("a128",$writeValue); print FOUT $writeValue;
84 $writeValue = $last2order->findvalue('@front_audio');
85 printf("FA:$writeValue ");
86 $writeValue = pack("a128",$writeValue); print FOUT $writeValue;
88 $writeValue = $last2order->findvalue('@rear_video');
89 printf("RV:$writeValue ");
90 $writeValue = pack("a128",$writeValue); print FOUT $writeValue;
92 $writeValue = $last2order->findvalue('@rear_audio');
93 printf("RA:$writeValue ");
94 $writeValue = pack("a128",$writeValue); print FOUT $writeValue;
96 $writeValue = $last2order->findvalue('@ordername');
97 printf("ON:$writeValue ");
98 $writeValue = pack("a64",$writeValue); print FOUT $writeValue;
105 system("rm $LOCAL_XML $LOCAL_DTD");