xsl-list
[Top] [All Lists]

Re: [xsl] Dividing a long document into seperate documents

2006-08-15 14:04:24

Hi,

Thanks for good suggestion. Based on your suggestion, I tried to modify xslt. But, it only generate one rdf document (rdf1.rdf). Could you take a look at my xslt? and suggest some tips to create multiple files from it.

Appreciate it advance, My XSLT: <?xml version="1.0"?>

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"; xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"; xmlns:dc="http://purl.org/dc/elements/1.1/"; xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"; >
                
<xsl:output encoding="UTF-8" method="xml" indent="yes" />
        
<xsl:template match="uiuc">
<xsl:for-each select="metadata/oai_dc:dc">
<xsl:result-document href="{concat('rdf', count(preceding-sibling::RDF) +1, '.rdf')}">

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"; xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"; xmlns:dc="http://purl.org/dc/elements/1.1/"; xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/";>
        
<xsl:variable name="identifier">
<xsl:value-of select="normalize-space(dc:identifier)"/>
</xsl:variable>
        <rdf:Description>
<xsl:attribute name="rdf:about"><xsl:value-of select="$identifier"/></xsl:attribute>
                <rdf:type rdf:resource="http://purl.org/gem/qualifiers/GEM2"/>
                <xsl:apply-templates select="dc:identifier"/>
                                <xsl:apply-templates select="dc:title"/>
                                <xsl:apply-templates select="dc:creator"/>
                                <xsl:apply-templates select="dc:subject"/>
                                <xsl:apply-templates select="dc:format"/>
                                <xsl:apply-templates select="dc:description"/>
                                <xsl:apply-templates select="dc:publisher"/>
                                <xsl:apply-templates select="dc:date"/>
                                <xsl:apply-templates select="dc:type"/>
                                <xsl:apply-templates select="dc:contributor"/>
                                <xsl:apply-templates select="dc:coverage"/>
                                <xsl:apply-templates select="dc:rights"/>
                                <xsl:apply-templates select="dc:language"/>
                        <xsl:apply-templates select="dc:relation"/>
                        <xsl:apply-templates select="dc:source"/>
                </rdf:Description>
                </rdf:RDF>    </xsl:result-document></xsl:for-each>
</xsl:template>

<xsl:template match="dc:identifier"> <dc:identifier rdf:resource="{normalize-space(.)}"/> </xsl:template>
        <xsl:template match="dc:title">
                <dc:title>
                        <xsl:value-of select="normalize-space(.)"/>
                </dc:title>
        </xsl:template><xsl:template match......


Cheers,
Ryan

From: "Jay Bryant" <jay(_at_)bryantcs(_dot_)com>
Reply-To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Subject: Re: [xsl] Dividing a long document into seperate documents
Date: Mon, 14 Aug 2006 22:49:08 -0500

Each file name has to be unique. To meet that requirement, you can create
filename strings from bits of data.

Suppose you have 3 RDF elements. Then you might do something like:

<xsl:template match="RDF">
<xsl:result-document href="{concat('rdf',
count(preceding-sibling::RDF) +
1, '.xml')}">
     <xsl:copy-of select="."/>
   </xslresult-document>
</xsl:template>

to get rdf1.xml, rdf2.xml, and rdf3.xml.

Jay Bryant
Bryant Communication Services

----- Original Message -----
From: "Choi Ryan" <yutaka234(_at_)hotmail(_dot_)com>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Monday, August 14, 2006 5:24 PM
Subject: Re: [xsl] Dividing a long document into seperate documents


> Thanks for a good suggestion..
>
> One more question.
>
> What do you mean by "concatenating information within the RDF record"?
>
> Thanks a lot,
>
> Cheers,
> Ryan
>
> >From: "Jay Bryant" <jay(_at_)bryantcs(_dot_)com>
> >Reply-To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
> >To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
> >Subject: Re: [xsl] Dividing a long document into seperate documents
> >Date: Mon, 14 Aug 2006 16:30:24 -0500
> >
> >If you are using XSLT 2.0, you can chop up a file with xsl:result
> document,
> >thus:
> >
> ><xsl:template match="RDF">
> >   <xsl:result-document href="sometitle">
> >     <xsl:copy-of select="."/>
> >   </xslresult-document>
> ></xsl:template>
> >
> >That will put each RDF element into its own file. Of course, you need
to
> >generate the "sometitle" value (probably by concatenating information
> within
> >the RDF record. You could also copy parts of the metadata at the top
of
> the
> >source file into the RDF files, if needed.
> >
> >If you are not using XSLT 2.0, you can still do this if you use a
> processor
> >that supports an extension function to write content to a file. I know
> Saxon
> >has such a function, and I bet many other processors do, too.
> >
> >HTH
> >
> >Jay Bryant
> >Bryant Communication Services
> >
> >----- Original Message -----
> >From: "Choi Ryan" <yutaka234(_at_)hotmail(_dot_)com>
> >To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
> >Sent: Monday, August 14, 2006 4:09 PM
> >Subject: [xsl] Dividing a long document into seperate documents
> >
> >
> > > Hi All,
> > >
> > > Sorry for a long posting.
> > > Actually, I transformed OAI Harvesting documents from XSLT. But,
OAI
> XML
> > > Document has multiple bindings as below..
> > >
> > > <uiuc>
> > > <metadata>
> > > <oai_dc:dc xmlns:dc="http://purl.org/dc/elements/1.1/";
> > > xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/";
> > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> > > xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/
> > >               http://www.openarchives.org/OAI/2.0/oai_dc.xsd";>
> > > <dc:title>Oldtown Folks</dc:title>
> > > <dc:creator>Stowe, Harriet Beecher, 1811-1896</dc:creator>
> > > <dc:subject>New England -- Social life and customs --
> >Fiction.</dc:subject>
> > > <dc:subject>Women -- New England -- Fiction.</dc:subject>
> > > <dc:subject>PS2954 .O4</dc:subject>
> > >
>

<dc:identifier>http://digital.library.upenn.edu/women/stowe/folks/folks.htm

l
>
> ></dc:identifier>
> > >
> > > <dc:format>text/html</dc:format>
> > > <dc:description>Boston: Fields, Osgood, and Co.,
1869</dc:description>
> > > <dc:publisher>Fields, Osgood, and Co.</dc:publisher>
> > > <dc:date>1869</dc:date>
> > > <dc:publisher>A Celebration of Women Writers</dc:publisher>
> > > <dc:date>2001-01-11</dc:date><dc:type>Text</dc:type>
> > > </oai_dc:dc>
> > > </metadata>
> > > <metadata>
> > > <oai_dc:dc xmlns:dc="http://purl.org/dc/elements/1.1/";
> > > xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/";
> > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> > > xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/
> > >               http://www.openarchives.org/OAI/2.0/oai_dc.xsd";>
> > > <dc:title>An Island Garden</dc:title>
> > > <dc:creator>Thaxter, Celia, 1835-1894</dc:creator>
> > > <dc:creator>Hassam, Childe</dc:creator>
> > > <dc:subject>Celia Thaxter's Garden (Appledore Island,
> Me.).</dc:subject>
> > > <dc:subject>Thaxter, Celia, 1835-1894.</dc:subject>
> > > <dc:subject>Gardens -- Maine -- Appledore Island.</dc:subject>
> > > <dc:subject>Appledore Island (Me.) -- Description and
> travel.</dc:subject>
> > > <dc:subject>SB466 .U6 T5</dc:subject>
> > >
>

<dc:identifier>http://digital.library.upenn.edu/women/thaxter/garden/garden

.
>
> >html</dc:identifier>
> > >
> > > <dc:format>text/html</dc:format>
> > > <dc:publisher>A Celebration of Women Writers</dc:publisher>
> > > <dc:date>2001-07-13</dc:date><dc:type>Text</dc:type>
> > > </oai_dc:dc>
> > >
</metadata><metadata>...</metadata><metadata>...</metadata>..</uiuc>
> > >
> > > So, my transformation also has multiple buildings as below.
However,
> > > actually, each rdf binding is seperate record. However, I do not
have
> any
> > > idea how to handle seperating this into seperate records. Could you
> give
> >me
> > > a tip or help?
> > >
> > > <rdf:RDF xmlns:content="http://purl.org/rss/1.0/modules/content/";
> > > xmlns:dc="http://purl.org/dc/elements/1.1/";
> > > xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/";
> > > xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
> > > xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#";
> > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
> > > <rdf:Description
> > >
>
rdf:about="http://digital.library.upenn.edu/women/stowe/folks/folks.html";>
> > > <rdf:type rdf:resource="http://purl.org/gem/qualifiers/GEM2"/>
> > > <dc:identifier
> > >
>

rdf:resource="http://digital.library.upenn.edu/women/stowe/folks/folks.html

"
>
> >/>
> > >
> > > <dc:title>Oldtown Folks</dc:title>
> > > <dc:creator>Stowe, Harriet Beecher, 1811-1896</dc:creator>
> > > <dc:subject>New England -- Social life and customs --
> > > Fiction.</dc:subject>
> > > <dc:subject>Women -- New England -- Fiction.</dc:subject>
> > > <dc:subject>PS2954 .O4</dc:subject>
> > > <dc:format>text/html</dc:format>
> > > <dc:description>Boston: Fields, Osgood, and Co.,
1869</dc:description>
> > > <dc:publisher>Fields, Osgood, and Co.</dc:publisher>
> > > <dc:publisher>A Celebration of Women Writers</dc:publisher>
> > > <dc:date>1869</dc:date>
> > > <dc:date>2001-01-11</dc:date>
> > > <dc:type>Text</dc:type>
> > > </rdf:Description>
> > > </rdf:RDF>
> > > <rdf:RDF xmlns:content="http://purl.org/rss/1.0/modules/content/";
> > > xmlns:dc="http://purl.org/dc/elements/1.1/";
> > > xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/";
> > > xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
> > > xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#";
> > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
> > > <rdf:Description
> > >
>

rdf:about="http://digital.library.upenn.edu/women/thaxter/garden/garden.htm

l
>
> >">
> > >
> > > <rdf:type rdf:resource="http://purl.org/gem/qualifiers/GEM2"/>
> > > <dc:identifier
> > >
>

rdf:resource="http://digital.library.upenn.edu/women/thaxter/garden/garden.

h
>
> >tml"/>
> > >
> > > <dc:title>An Island Garden</dc:title>
> > > <dc:creator>Thaxter, Celia, 1835-1894</dc:creator>
> > > <dc:creator>Hassam, Childe</dc:creator>
> > > <dc:subject>Celia Thaxter's Garden (Appledore Island,
> Me.).</dc:subject>
> > > <dc:subject>Thaxter, Celia, 1835-1894.</dc:subject>
> > > <dc:subject>Gardens -- Maine -- Appledore Island.</dc:subject>
> > > <dc:subject>Appledore Island (Me.) -- Description and
> > > travel.</dc:subject>
> > > <dc:subject>SB466 .U6 T5</dc:subject>
> > > <dc:format>text/html</dc:format>
> > > <dc:publisher>A Celebration of Women Writers</dc:publisher>
> > > <dc:date>2001-07-13</dc:date>
> > > <dc:type>Text</dc:type>
> > > </rdf:Description>
> > > </rdf:RDF>
> > > <rdf:RDF>...</rdf:RDF><rdf:RDF>...</rdf:RDF><rdf:RDF>...</rdf:RDF>
> > >
> > > Thanks a lot,
> > >
> > > Cheers,
> > > Ryan
> > >
> > > _________________________________________________________________
> > > 책상위에 다리 올리고 느긋하게 즐긴다... MSN 온라인 상영관
> > > http://vod.msn.co.kr
> > >
> > >
> > >
--~------------------------------------------------------------------
> > > XSL-List info and archive:
http://www.mulberrytech.com/xsl/xsl-list
> > > To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
> > > or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
> > > --~--
> > >
> >
> >
> >
> >--~------------------------------------------------------------------
> >XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> >To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
> >or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
> >--~--
> >
>
> _________________________________________________________________
> 증권 정보 가장 빠르고 편하게 보실 수 있습니다. MSN 증권/투자
> http://www.msn.co.kr/stock/
>
>
> --~------------------------------------------------------------------
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
> or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
> --~--
>



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


_________________________________________________________________
보다 빠르고 보기 편한 뉴스. 오늘의 화제는 MSN 뉴스에서 확인하세요. http://www.msn.co.kr/news/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--