To copy everything I use this xsl:

 

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >


<!-- identityTransform.xsl -->
<!-- Match the root node -->

<xsl:template match="/">
      <xsl:apply-templates select="*"/>
</xsl:template>
  
<!-- Match everything else -->
<xsl:template match="*|@*|text()|comment()">
      <xsl:copy>
  <xsl:apply-templates select="*|@*|text()|comment()"/>
 </xsl:copy>
</xsl:template>

</xsl:stylesheet>

 

It works and I use to eventually add or modify something while capturing all the rest.

 

Ciao,

Giovanni

 

----Messaggio originale----
Da: [log in to unmask]
Data: 28/10/2011 20.22
A: <[log in to unmask]>
Ogg: Re: Stylesheet Help

That did the trick! Thanks so much Michele and everyone else for your help and the references!


Nathan

On Fri, Oct 28, 2011 at 1:07 PM, Michele R Combs <[log in to unmask]> wrote:

Hm, interesting question.    You might try adding processing-instruction to the match rule that captures everything and passes it through, so rather than this:

 

<xsl:template match="*">

 

you could try this:

 

<xsl:template match="*|processing-instruction()">

 

Or, to be really thorough a:

 

<xsl:template match="@*|*|text()|comment()|processing-instruction()">

 

However, since it’s outside the root element I don’t know if it will get captured or not.  The other option would be to run your files through in batches and edit the XSL accordingly to output the xml-stylesheet for each batch.

 

By the way, this page http://www.xmlplease.com/xsltidentity has a great discussion of this “identity template” (“The so-called identity template that copies everything from input.xml to output.xml, element for element, attribute for attribute, is the most important of all templates in combination with templates of exceptions.”).  It gives a bunch of examples of code snippets you can add to do various things, with input and output examples.

 

Michele

 

From: Encoded Archival Description List [mailto:[log in to unmask]] On Behalf Of Nathan Tallman
Sent: Friday, October 28, 2011 12:09 PM


To: [log in to unmask]
Subject: Re: Stylesheet Help

 

 

Hi Michele,

 

Thanks for sending me your global change template. I was able to modify it to include the DOCTYPE declaration. But, it's removing my stylesheet declaration <?xml-stylesheet type="text/xsl" href="../common/html.xsl"?>. Is there anyway to retain this? Otherwise, your merge style sheet does exactly what I need it too, thanks!

 

Thanks also to Michael and Dan! (Dan, I just made a typo with that extra closing tag, but thanks for the catch.)

 

Thanks again,

Nathan

 

On Fri, Oct 28, 2011 at 11:15 AM, Michele R Combs <[log in to unmask]> wrote:

Hi Nathan –

 

I have a style sheet – it’s only 18 lines – that does nothing but pass an EAD file through unchanged.  You can then insert any desired code to do one single thing (such as this).  It’s a bit like a denucleated cell: you can stick in any DNA you like and make all sort of different things come out :)  It’s quite handy, and I’ve used it in the past to make global changes to our EAD files. 

 

Some nice person on the EAD list gave it to me a while back but their name isn’t in the file and I can’t remember who it was (Mike Rush, maybe?  Mark Matienzo?), so I can’t acknowledge them except anonymously:  Thank you, whoever you were!

 

I can’t remember if the EAD list allows attachments so I’ll send it to you separately.

 

Michele

 

 

From: Encoded Archival Description List [mailto:[log in to unmask]] On Behalf Of Nathan Tallman
Sent: Friday, October 28, 2011 10:39 AM
To: [log in to unmask]
Subject: Stylesheet Help

 

Is it possible to write an XSL stylesheet to flatten the controlled access terms? We'd like to shift from encoding like this:

 

                        <controlaccess>

                                    <head>Search Terms</head>

                                    <note>

                                                <p>The following terms have been used to index the description of this collection in

                                                            the American Jewish Archives's online catalog.</p>

                                    </note>

                                    <controlaccess>

                                                <head>Contributors</head>

                                                <persname source="lcnaf" encodinganalog="700" />

                                    </controlaccess>

                                    <controlaccess>

                                                <head>Subjects</head>

                                                <persname encodinganalog="600" source="lcnaf" />

                                                <corpname encodinganalog="610" source="lcnaf" />

                                                <subject source="lcsh" encodinganalog="650" />

                                                <occupation encodinganalog="656" source="lcsh" />

                                                <geogname encodinganalog="651" source="lcnaf" />

                                    </controlaccess>

                                    <controlaccess>

                                                <head>Genres</head>

                                                <genreform encodinganalog="655" source="lcsh">LCSH</genreform>

                                    </controlaccess>

                        </controlaccess>

 

to this:

 

                        <controlaccess>

                                    <head>Search Terms</head>

                                    <note>

                                                <p>The following terms have been used to index the description of this collection in

                                                            the American Jewish Archives's online catalog.</p>

                                    </note>                                               

                                                <persname source="lcnaf" encodinganalog="700" />

                                                <persname encodinganalog="600" source="lcnaf" />

                                                <corpname encodinganalog="610" source="lcnaf" />

                                                <subject source="lcsh" encodinganalog="650" />

                                                <occupation encodinganalog="656" source="lcsh" />

                                                <geogname encodinganalog="651" source="lcnaf" />

                                                <genreform encodinganalog="655" source="lcsh" />

                                    </controlaccess>

                        </controlaccess>

 

And let the HTML/PDF stylesheets do the sorting. Alas, I have about 800 finding aids encoded in the former example that need to be converted. Any help would be much appreciated!

 

Many thanks,

Nathan