Sign In | Register Now About Bytes | Help | Site Map
Connecting Tech Pros Worldwide

XLST - Help needed to write the XSL (2)

Question posted by: sarah12 (Newbie) on June 27th, 2008 10:21 AM
HI,

This time , I need to write the XSL to transform the following document :

<?xml version="1.0"?>
<nplbiblio rundate="20080110">
<document status="U" creadate="19990410">
<xp>000000028876</xp>
<doctype>ABSTRACT</doctype>
<prdate>19880131</prdate>
<ord>19880131</ord>
<titles>
<title> CREEP BEHAVIOR OF GLASS FIBER-REINFORCED HARDBOARD.</title>
</titles>
<author>SMULSKI S. J., IFJU G.</author>
<supplier>MIGRATION</supplier>
<attribs>
<attrib name="nr_hostdoc">07</attrib>
<attrib name="pg_abs">940</attrib>
<attrib name="vol_hostdoc">58</attrib>
</attribs>
<publication>
<pubtitle>ABSTRACT BULLETIN OF THE INSTITUTE OF PAPER CHEMISTRY.</pubtitle>
<pubname>THE INSTITUTE OF PAPER CHEMISTRY-LIBRARY. APPLETON.</pubname>
<pubaddr>US</pubaddr>
<pubattr>
<attrib name="magno_hostdoc">0005500</attrib>
<attrib name="vnum_hostdoc">1004</attrib>
</pubattr>
</publication>
</document>
</nplbiblio>



into :

<?xml version="1.0" ?>
<nplbiblio rundate="20080110">
<document status="U" creadate="19990410">
<xp>000000028876</xp>
<doctype>ABSTRACT</doctype>
<prdate>19880131</prdate>
<ord>19880131</ord>

<title language=" ">CREEP BEHAVIOR OF GLASS FIBER-REINFORCED HARDBOARD.</title>

<author>SMULSKI S. J., IFJU G.</author>
<supplier>MIGRATION</supplier>

<issue>07</issue>
<first_page> 940.</first_page>
<volume>58</volume>

<pubtitle>ABSTRACT BULLETIN OF THE INSTITUTE OF PAPER CHEMISTRY.</pubtitle>

<pubname>THE INSTITUTE OF PAPER CHEMISTRY-LIBRARY. APPLETON.</pubname>

<pubaddr>US</pubaddr>

</document>
</nplbiblio>


The transformations required is to :
- Extract only some specific tags and their data
- Make some sub level tags as main level tags
- Change the name of some tags

Can you help ?

I have written this xlst :

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:npl="http://www.epo.org/npl" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:output method="xml" doctype-system="npl-entities.dtd"/>
<xsl:template match="/">
<nplbiblio>
<xsl:attribute name="xsi:noNamespaceSchemaLocation">npldoc v2.0.xsd</xsl:attribute>
<xsl:attribute name="rundate">20080123</xsl:attribute>
<xsl:for-each select="nplbiblio/document">
<document status="n">
<xsl:attribute name="creadate">20080123</xsl:attribute>

<xsl:copy-of select="xp"/>
<xsl:copy-of select="doctype"/>
<xsl:copy-of select="prdate"/>
<xsl:copy-of select="xp"/>
<xsl:copy-of select="author"/>
<xsl:copy-of select="supplier"/>

<title>
<xsl:value-of select="title"/>
</title>

<first_page">
<xsl:value-of select="pg_from_hostdoc"/>
</first_page">
<volume>
<xsl:value-of select="vol_from_hostdoc"/>
</volume>
<issue>
<xsl:value-of select="nr_from_hostdoc"/>
</issue>
<issn>
<xsl:value-of select="issn"/>
</issn>

<isbn>
<xsl:value-of select="isbn"/>
</isbn>

</document>
</xsl:for-each>
</nplbiblio>
</xsl:template>
</xsl:stylesheet>


But I keep getting errors....
sarah12's Avatar
sarah12
Newbie
8 Posts
June 27th, 2008
02:20 PM
#2

Re: XLST - Help needed to write the XSL (2)
My last xslt :


<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:npl="http://www.epo.org/npl" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:output method="xml" doctype-system="npl-entities.dtd"/>
<xsl:template match="/">
<nplbiblio>
<xsl:attribute name="xsi:noNamespaceSchemaLocation">npldoc v2.0.xsd</xsl:attribute>
<xsl:attribute name="rundate">20080123</xsl:attribute>
<xsl:for-each select="nplbiblio/document">
<document status="n">
<xsl:attribute name="creadate">20080123</xsl:attribute>

<xsl:copy-of select="xp"/>
<xsl:copy-of select="doctype"/>
<xsl:copy-of select="prdate"/>
<xsl:copy-of select="xp"/>
<xsl:copy-of select="author"/>
<xsl:copy-of select="supplier"/>

<title>
<xsl:value-of select="document/titles/title"/>
</title>

<isbn>
<xsl:value-of select="document/publication/irn/isbn"/>
</isbn>

<issn>
<xsl:value-of select="document/publication/irn/issn"/>
</issn>

<first_page>
<xsl:value-of select="document/attribs/attrib name=pg_from_hostdoc"/>
</first_page>

<volume>
<xsl:value-of select="document/attribs/attrib name=vol_from_hostdoc"/>
</volume>

<issue>
<xsl:value-of select="document/attribs/attrib name=nr_from_hostdoc"/>
</issue>

</document>
</xsl:for-each>
</nplbiblio>
</xsl:template>
</xsl:stylesheet>

Reply
Reply
Not the answer you were looking for? Post your question . . .
189,847 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
Top XML Forum Contributors