8 use Unicode::Normalize;
12 my ($split,$enc,$marc,$out,$bad) = (100);
16 'encoding=s' => \$enc,
22 MARC::Charset->ignore_errors(1);
23 MARC::Charset->assume_encoding($enc);
26 die "gimme some marc!\n" unless $marc;
27 die "gimme somewhere to put it!\n" unless $out;
29 my $xsl = join('',(<DATA>));
31 my $parser = XML::LibXML->new();
32 my $xslt = XML::LibXSLT->new();
34 $stylesheet = $xslt->parse_stylesheet( $parser->parse_string($xsl) );
36 $bad = new FileHandle( $bad => '>:raw' ) if ($bad);
43 my $marc = MARC::Batch->new( USMARC => $marc );
47 while (my $r = $marc->next) {
48 my $rxml = entityize(MARC::File::XML::record($r));
49 $rxml =~ s/[\x00-\x1f]//go;
51 try { $doc = $parser->parse_string($rxml); }
54 warn "arg ... bad record $current, skipping: $e\n";
56 print $bad $r->as_usmarc if ($bad);
63 unless ($current % $split) {
65 <collection xmlns="http://www.loc.gov/MARC21/slim">
71 try { $doc = $parser->parse_string($xml); }
72 catch Error with { my $e = shift; warn "ARG! Doc failed to parse:\n$e\n-------------------------------------------\n$xml\n"; };
77 my $results = $stylesheet->transform($doc, prev => "'$prev'", next => "'$next'");
81 open OUT, ">$out/$prev.html";
82 print OUT $results->toString;
88 my $doc = $parser->parse_string(<<XML);
89 <marc:collection xmlns:marc="http://www.loc.gov/MARC21/slim">
94 my $results = $stylesheet->transform($doc, prev => "'$prev'", next => "'0'");
97 $stylesheet->output_file($results, "$out/$prev.html");
105 $stuff = NFD($stuff);
107 $stuff = NFC($stuff);
110 $stuff =~ s/([\x{0080}-\x{fffd}])/sprintf('&#x%X;',ord($1))/sgoe;
111 $stuff =~ s/([\x00-\x19])//sgoe;
118 <?xml version="1.0" encoding="UTF-8"?>
119 <xsl:stylesheet version="1.0" xmlns:marc="http://www.loc.gov/MARC21/slim" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
120 <xsl:output method="html"/>
122 <xsl:template match="/">
134 .marc_subfield_code {
142 <link href='/css/opac_marc.css' rel='stylesheet' type='text/css'></link>
145 <xsl:if test="$prev > 0">
147 <xsl:attribute name="href">
148 <xsl:value-of select="concat( $prev, '.html')"/>
150 <xsl:text>Previous page</xsl:text>
154 <xsl:if test="$next > 0">
156 <xsl:attribute name="href">
157 <xsl:value-of select="concat( $next, '.html')"/>
159 <xsl:text>Next page</xsl:text>
163 <xsl:apply-templates select="//marc:record"/>
164 <xsl:if test="$prev > 0">
166 <xsl:attribute name="href">
167 <xsl:value-of select="concat( $prev, '.html')"/>
169 <xsl:text>Previous page</xsl:text>
173 <xsl:if test="$next > 0">
175 <xsl:attribute name="href">
176 <xsl:value-of select="concat( $next, '.html')"/>
178 <xsl:text>Next page</xsl:text>
185 <xsl:template match="marc:record">
186 <table class='marc_table'>
187 <tr class='marc_tag_row'>
188 <th class='marc_tag_col' NOWRAP="TRUE" ALIGN="RIGHT" VALIGN="middle">
191 <td class='marc_tag_data' COLSPAN='3'>
192 <xsl:value-of select="marc:leader"/>
195 <xsl:apply-templates select="marc:datafield|marc:controlfield"/>
200 <xsl:template match="marc:controlfield">
201 <tr class='marc_tag_row'>
202 <th class='marc_tag_col' NOWRAP="TRUE" ALIGN="RIGHT" VALIGN="middle">
203 <xsl:value-of select="@tag"/>
205 <td class='marc_tag_data' COLSPAN='3'>
206 <xsl:value-of select="."/>
211 <xsl:template match="marc:datafield">
212 <tr class='marc_tag_row'>
213 <th class='marc_tag_col' NOWRAP="TRUE" ALIGN="RIGHT" VALIGN="middle">
214 <xsl:value-of select="@tag"/>
216 <td class='marc_tag_ind'>
217 <xsl:value-of select="@ind1"/>
220 <td class='marc_tag_ind' style='border-left: 1px solid #A0A0A0; padding-left: 3px;'>
221 <xsl:value-of select="@ind2"/>
222 <span style='color:#FFF'>.</span>
225 <td class='marc_subfields'>
226 <xsl:apply-templates select="marc:subfield"/>
231 <xsl:template match="marc:subfield">
232 <span class='marc_subfield_code' >
233 ‡<xsl:value-of select="@code"/>
234 </span><xsl:value-of select="."/>