Print

Print


Marsha,

Michele's answer illustrates the two different types of stylesheets you
might use.

The first template shows the classical "pull" method where a single
template matches the root element, here marc:record; adds the EAD syntax;
and flows the content of the MARC records into the new EAD shell using
xsl:value-of.   xsl:if and xsl:choose elements are used to test for the
appearance of given source elements.  Use xsl:for-each loops when there are
instances of multiple identical MARC elements (say several 650 topical
subject headings) to be processed.

By using xsl:value-of instead of xsl:apply-templates, one avoids invoking
the default template, to answer your earlier question.

The subsequent templates illustrate the basic outline of the "push" method,
if not its full power and complexity.

While I would not normally advise the pull method in transforming EAD, this
approach has advantages in situations like this- where the content of the
source data (MARC) appears in a given sequence, is structurally predicable
(mostly) in content, and lacks complex hierarchy.   And where the
stylesheet is not so long as to be difficult to maintain and interpret.

In fact, it is the linearity of pull stylesheets (following the sequence of
data in the output document) that often makes them easier to write and
analyze in situations like this.

Michael Fox





On Tue , Jul 3, 2012 at 11:20 AM, Michele R Combs <[log in to unmask]> wrote:

>  Hi Marsha �****
>
> ** **
>
> For the MARCXML extraction it�s super simple.  All you need is something
> like this:****
>
> ** **
>
> <xsl:template match="marc:record">****
>
>                 <c02>****
>
>                                 <unittitle><xsl:value-of
> select="marc:datafield[@tag='245']"/></unittitle>****
>
>                                 <unitdate><xsl:value-of
> select="marc:datafield[@tag='260']/marc:subfield[@code='c']"/></unitdate>*
> ***
>
>                   </c02>****
>
> </xsl:template>****
>
> ** **
>
> Since the MARCXML structure is really flat, you can just add more lines to
> output whatever EAD tags you want, and grab the data from whatever
> datafield or subfield you want.****
>
> ** **
>
> If you need to massage the data for a particular tag before spitting it
> out, then you can write little templates for each of the MARC tags you want
> to use, and then call them where you want them, like so:****
>
> ** **
>
> <xsl:template match="marc:record">****
>
>                 <c02>****
>
>                                 <unittitle><xsl:apply-templates
> select="marc:datafield[@tag='245']"/></unittitle>****
>
>                                 <unitdate><xsl:apply-templates
> select="marc:datafield[@tag='260']/marc:subfield[@code='c']"/></unitdate>*
> ***
>
>                   </c02>****
>
> </xsl:template>****
>
> ** **
>
> <xsl:template match="marc:datafield[@tag='245']">****
>
>    <!-- do whatever you want here, e.g. normalize data, remove
> punctuation, etc etc etc -->****
>
> </xsl:template>****
>
> ** **
>
> <xsl:template match="marc:datafield[@tag='260']/></****
>
>    <!-- do whatever you want here, e.g. normalize data, remove
> punctuation, etc etc etc -->****
>
> </xsl:template>****
>
> ** **
>
> For different ways of handling and outputting fields and subfields, I�d
> encourage you to look at the MARC to EAD style sheets provided by
> MARCEDIT.  Lots of good examples in there.****
>
> ** **
>
> For your �buried data� problem, it depends on what sort of structure you
> have. If the elements are uniquely named (like in EAD, you used c01, c02,
> c03), then you can �grab� them by name without worrying about the XPATH.
> If on the other hand every level of the structure is named the same (like
> in EAD, if you used <c> for all your levels) then yeah, you�ll have to
> figure out a way to specify the exact one(s) you�re looking for, either by
> level or ID or something else.****
>
> ** **
>
> For setting up transformations, you can use MARCEDIT�s GUI to set up your
> own XSL transformations, which might be useful, but unfortunately its XSL
> error reporting is *awful*.  I would go with something like Saxon, which
> does a much better job � it gives you the line number of any errors and
> usually a useful description of what the error is.****
>
> ** **
>
> Any web  browser can certainly open an XML document, but of course it
> won�t format it pretty unless you�ve attached it to a stylesheet.****
>
> ** **
>
> Hope this helps.****
>
> ** **
>
> Michele****
>
> ** **
>
> *From:* Encoded Archival Description List [mailto:[log in to unmask]] *On
> Behalf Of *Marsha Maguire
> *Sent:* Tuesday, July 03, 2012 11:02 AM
> *To:* [log in to unmask]
> *Subject:* Simple XML to EAD conversions with XSLT****
>
> ** **
>
> Hello, EAD XSLT experts and thank you so very much for your replies.
>
> Richmond is very close, so I'll have to look into the MARAC workshop
> there, as well as the XSL e-list -- thank you, Michele!  I love MarcEdit
> and used it to capture a test batch of MARC records, but as Michael Fox
> says, MarcEdit converts MARC to collection-level EAD. I want to convert
> MARC records for a few hundred early sound discs, most containing music,
> into c02-level inventory entries in a finding aid for a larger,
> multi-format collection. I'd like to capture some of the ID numbers in the
> MARC records: 050, 028, a link containing the 010 permalink in case users
> want to see the complete original MARC record, the 1XX main entry when it's
> there (not always), most of the 245 subfields (sometimes there are also
> uniform titles in 130/240 fields, and I'd like to carry those over, too),
> the 260 imprint info, the *first *300 physical description field (there
> are often multiple 300 fields in these MARC records), and selected 5XX
> notes (511, and 500 notes that begin with a specific word). And the MARC
> 856 would map to EAD <extref> for linking to digital content.
>
> I have all this mapped to EAD, and I know XSLT can do what I need, but I
> don't know how to put the XSLT instructions together or quite where to
> start. What's the first step -- create a template for the root of the
> MARCXML file and then use mostly xsl:for-each and xsl:value-of
> instructions? How does one override the XSLT default templates? Do I need
> to write a template for every possible node in the MARCXML records and then
> not activate the nodes I don't want (not use xsl:apply-templates on those
> nodes, i.e.)? Or something?
>
> My other project involves converting XML records that have been
> auto-generated from an in-house database (I can't control what gets
> exported) into c02-level EAD descriptions. Some of the data I need is 8 or
> 9 levels of hierarchy deep in the source document, so I need to learn about
> XPath statements, right? Again, I think I need to override the XSLT default
> templates because I really only want a little data -- 6 or 7 fields -- in
> the converted output. I look at sites like W3 Schools (which almost seems
> too simple for what I need to do -- ?) and then stylesheets that begin by
> stating a bunch of variables (yikes!) and wonder if there is a happy medium
> to follow. Not sure how best to transform the docs while testing, either.
> I'm using XMLQuire to prepare the XSLT. To transform some very simple
> documents (XML to HTML, just a few elements), I was able to open the
> converted file in Internet Explorer 9, but can IE display a doc I've
> converted to XML? Maybe I need something like Saxon for that -- ?
>
> You all are so generous with your time and expertise. I really do want to
> learn how to do this myself so i don't always have to ask people like you!
> Again, many thanks!
>
> Marsha****
>



-- 
Michael Fox