Page 1 of 1

Do you have any sample stylesheet to convert xml to TabDeli

Posted: Wed Oct 29, 2008 4:51 pm
by rajendrasedhain
Hi guys,admin

I am really new and suffering to convert dublin core xml file to tab delimited file.if you guys have any sample,please help me I'll customize that according my needs.


My result is in a line, I can't break the line,when I use <br/> it comes with the output.I am new in this language I hope you'll help me to figure out.

My style sheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xpath-default-namespace="http://purl.org/dc/elements/1.1/"
xmlns:oclcterms="http://purl.org/oclc/terms/"
xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcmitype="http://purl.org/dc/dcmitype/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<xsl:template match="dctermset">

Source: NumberIdentifier: Date:

<xsl:element name="table">
<xsl:element name="tr">
<xsl:element name="td">
<xsl:for-each select="*">
<xsl:value-of select="oclcterms:recordContentSource" xml:space="">
</xsl:value-of>
</xsl:for-each>

</xsl:element>
</xsl:element>

<xsl:for-each select="*">
<xsl:value-of select="oclcterms:recordControlNumberIdentifier" separator="#x20"></xsl:value-of>

</xsl:for-each>

<xsl:for-each select="*">
<xsl:value-of select="oclcterms:recordCreationDate" separator="#x20"></xsl:value-of>

</xsl:for-each>

</xsl:element>

</xsl:template>
<xsl:strip-space elements=""/>

</xsl:stylesheet>

MY XML file:

This is the one portion (<oclcdcq />):

<?xml version="1.0" encoding="UTF-8" ?>
<dctermset><oclcdcq xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:oclcterms="http://purl.org/oclc/terms/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<oclcterms:recordContentSource>SRS</oclcterms:recordContentSource>
<oclcterms:recordControlNumberIdentifier xsi:type="http://purl.org/oclc/terms/marcorg">OCo ... Identifier>
<oclcterms:recordCreationDate xsi:type="http://purl.org/oclc/terms/marc008date" ... eationDate>
<oclcterms:recordIdentifier xsi:type="http://purl.org/oclc/terms/oclcrecordnu ... Identifier>
<oclcterms:OCLC-MARCProcessingInformation xsi:type="http://purl.org/oclc/terms/oclcorg">NUI ... nformation>
<oclcterms:OCLC-MARCProcessingInformation xsi:type="http://purl.org/oclc/terms/transactionc ... nformation>
<oclcterms:recordTranscribingAgency>SRS</oclcterms:recordTranscribingAgency>
<dc:contributor>United States. Dept. of Agriculture.</dc:contributor>
<dcterms:issued>1987?]</dcterms:issued>
<dc:description>Shipping list no.: 87-82-P.</dc:description>
<dcterms:extent>1 poster : col. ; 56 x 44 cm.</dcterms:extent>
<dc:language xsi:type="http://purl.org/dc/terms/ISO639-2">eng</dc:language>
<dc:publisher>U.S. Dept. of Agriculture</dc:publisher>
<dc:subject xsi:type="http://purl.org/dc/terms/LCSH">Conservation of natural resources--United States--Posters.</dc:subject>
<dc:subject>A 1.32:Am 3/2</dc:subject>
<dc:title>America's resources need your help!</dc:title>
<dc:type>Image</dc:type>
</oclcdcq>
</dctermset>

Output:

<?xml version="1.0" encoding="utf-8"?>

Source: NumberIdentifier: Date:

<table><tr><td>SRSGPOGPOGPOGPOOCOGPOIMFGPOGPO</td></tr>OCoLCOCoLCOCoLCOCoLCOCoLCOCoLCOCoLCOCoLCOCoLCOCoLC871116931013901231901231071213070601040108031118071016040315</table>

I want to put data, all the source data goes below the source header and same to other and they should have 'tab' space between them.

Thanks
-Raj

Re: Do you have any sample stylesheet to convert xml to TabDeli

Posted: Wed Oct 29, 2008 9:40 pm
by rajendrasedhain
How I can give new line ?

I did this:

<xsl:variable name="tab" select="' '" />
<xsl:variable name="newline" select="'
'" />
<xsl:preserve-space elements="*"/>

<xsl:template match="dctermset">

Source: NumberIdentifier: Date:
<xsl:for-each select="*">
<xsl:value-of select="oclcterms:recordContentSource" />
<xsl:value-of select="$newline" />
<xsl:value-of select="$tab" />
<xsl:value-of select="$newline" />
</xsl:for-each>

The Tab is working but the new line is not working how can I give new line ?
Please suggest me.

Thanks

Re: Do you have any sample stylesheet to convert xml to TabDeli

Posted: Wed Oct 29, 2008 11:07 pm
by rajendrasedhain
Finally, I solved the problem, it works now.

Thanks