#!/usr/bin/perl # Convert the RFC Editor's XML RFC index into a BibTex format $file=$ARGV[0]; die("Input file must have a .xml extension") unless $file=~/(.*)\.xml$/; if($#ARGV==0){ $output_file="$1.bib"; } elsif($#ARGV==1){ $output_file=$ARGV[1]; } else{ &usage; } use XML::Simple qw(:strict); my $db=XMLin($file,forcearray=>[qw(rfc-entry author)],keyattr => [] ); open(OUT,">$output_file")||die("Couldn't open output file $output_file for writing: $!"); $rfc_entry=$db->{'rfc-entry'}; foreach my $entry (@$rfc_entry){ $rfc_id=$entry->{'doc-id'}; die("bad format") unless $rfc_id=~/^RFC0*(\d+)$/; $rfc_number="RFC $1"; $rfc_title=$entry->{'title'}; $rfc_year=$entry->{'date'}->{'year'}; $rfc_month=$entry->{'date'}->{'month'}; $rfc_day=$entry->{'date'}->{'day'}; @rfc_authors=(); foreach my $author (@{$entry->{'author'}}) { push(@rfc_authors,$author->{'name'}); } $rfc_authors=join(" and ",@rfc_authors); print OUT < [] FOO }