8 use Unicode::Normalize;
11 my ($split,$enc,$marc,$out) = (100);
15 'encoding=s' => \$enc,
20 MARC::Charset->ignore_errors(1);
21 MARC::Charset->assume_encoding($enc);
24 die "gimme some marc!\n" unless $marc;
25 die "gimme somewhere to put it!\n" unless $out;
27 my $xsl = join('',(<DATA>));
29 my $parser = XML::LibXML->new();
30 my $xslt = XML::LibXSLT->new();
32 $stylesheet = $xslt->parse_stylesheet( $parser->parse_string($xsl) );
40 my $marc = MARC::Batch->new( USMARC => $marc );
44 while (my $r = $marc->next) {
45 $xml .= entityize(MARC::File::XML::record($r));
47 unless ($current % $split) {
49 <collection xmlns="http://www.loc.gov/MARC21/slim">
54 my $doc = $parser->parse_string($xml);
57 my $results = $stylesheet->transform($doc, prev => "'$prev'", next => "'$next'");
61 open OUT, ">$out/$prev.html";
62 print OUT $results->toString;
68 my $doc = $parser->parse_string(<<XML);
69 <marc:collection xmlns:marc="http://www.loc.gov/MARC21/slim">
74 my $results = $stylesheet->transform($doc, prev => "'$prev'", next => "'0'");
77 $stylesheet->output_file($results, "$out/$prev.html");
90 $stuff =~ s/([\x{0080}-\x{fffd}])/sprintf('&#x%X;',ord($1))/sgoe;
91 $stuff =~ s/([\x00-\x19])//sgoe;
98 <?xml version="1.0" encoding="UTF-8"?>
99 <xsl:stylesheet version="1.0" xmlns:marc="http://www.loc.gov/MARC21/slim" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
100 <xsl:output method="html"/>
102 <xsl:template match="/">
114 .marc_subfield_code {
122 <link href='/css/opac_marc.css' rel='stylesheet' type='text/css'></link>
125 <xsl:if test="$prev > 0">
127 <xsl:attribute name="href">
128 <xsl:value-of select="concat( $prev, '.html')"/>
130 <xsl:text>Previous page</xsl:text>
134 <xsl:if test="$next > 0">
136 <xsl:attribute name="href">
137 <xsl:value-of select="concat( $next, '.html')"/>
139 <xsl:text>Next page</xsl:text>
143 <xsl:apply-templates select="//marc:record"/>
144 <xsl:if test="$prev > 0">
146 <xsl:attribute name="href">
147 <xsl:value-of select="concat( $prev, '.html')"/>
149 <xsl:text>Previous page</xsl:text>
153 <xsl:if test="$next > 0">
155 <xsl:attribute name="href">
156 <xsl:value-of select="concat( $next, '.html')"/>
158 <xsl:text>Next page</xsl:text>
165 <xsl:template match="marc:record">
166 <table class='marc_table'>
167 <tr class='marc_tag_row'>
168 <th class='marc_tag_col' NOWRAP="TRUE" ALIGN="RIGHT" VALIGN="middle">
171 <td class='marc_tag_data' COLSPAN='3'>
172 <xsl:value-of select="marc:leader"/>
175 <xsl:apply-templates select="marc:datafield|marc:controlfield"/>
180 <xsl:template match="marc:controlfield">
181 <tr class='marc_tag_row'>
182 <th class='marc_tag_col' NOWRAP="TRUE" ALIGN="RIGHT" VALIGN="middle">
183 <xsl:value-of select="@tag"/>
185 <td class='marc_tag_data' COLSPAN='3'>
186 <xsl:value-of select="."/>
191 <xsl:template match="marc:datafield">
192 <tr class='marc_tag_row'>
193 <th class='marc_tag_col' NOWRAP="TRUE" ALIGN="RIGHT" VALIGN="middle">
194 <xsl:value-of select="@tag"/>
196 <td class='marc_tag_ind'>
197 <xsl:value-of select="@ind1"/>
200 <td class='marc_tag_ind' style='border-left: 1px solid #A0A0A0; padding-left: 3px;'>
201 <xsl:value-of select="@ind2"/>
202 <span style='color:#FFF'>.</span>
205 <td class='marc_subfields'>
206 <xsl:apply-templates select="marc:subfield"/>
211 <xsl:template match="marc:subfield">
212 <span class='marc_subfield_code' >
213 ‡<xsl:value-of select="@code"/>
214 </span><xsl:value-of select="."/>