XLST - Help needed to write the XSL (2)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sarah12
    New Member
    • Jun 2008
    • 8

    XLST - Help needed to write the XSL (2)

    HI,

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

    <?xml version="1.0"?>
    <nplbiblio rundate="200801 10">
    <document status="U" creadate="19990 410">
    <xp>00000002887 6</xp>
    <doctype>ABSTRA CT</doctype>
    <prdate>1988013 1</prdate>
    <ord>19880131 </ord>
    <titles>
    <title> CREEP BEHAVIOR OF GLASS FIBER-REINFORCED HARDBOARD.</title>
    </titles>
    <author>SMULS KI S. J., IFJU G.</author>
    <supplier>MIGRA TION</supplier>
    <attribs>
    <attrib name="nr_hostdo c">07</attrib>
    <attrib name="pg_abs">9 40</attrib>
    <attrib name="vol_hostd oc">58</attrib>
    </attribs>
    <publication>
    <pubtitle>ABSTR ACT BULLETIN OF THE INSTITUTE OF PAPER CHEMISTRY.</pubtitle>
    <pubname>THE INSTITUTE OF PAPER CHEMISTRY-LIBRARY. APPLETON.</pubname>
    <pubaddr>US</pubaddr>
    <pubattr>
    <attrib name="magno_hos tdoc">0005500</attrib>
    <attrib name="vnum_host doc">1004</attrib>
    </pubattr>
    </publication>
    </document>
    </nplbiblio>



    into :

    <?xml version="1.0" ?>
    <nplbiblio rundate="200801 10">
    <document status="U" creadate="19990 410">
    <xp>00000002887 6</xp>
    <doctype>ABSTRA CT</doctype>
    <prdate>1988013 1</prdate>
    <ord>19880131 </ord>

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

    <author>SMULS KI S. J., IFJU G.</author>
    <supplier>MIGRA TION</supplier>

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

    <pubtitle>ABSTR ACT 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:styleshe et 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:attribut e name="xsi:noNam espaceSchemaLoc ation">npldoc v2.0.xsd</xsl:attribute>
    <xsl:attribut e name="rundate"> 20080123</xsl:attribute>
    <xsl:for-each select="nplbibl io/document">
    <document status="n">
    <xsl:attribut e 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="supplie r"/>

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

    <first_page">
    <xsl:value-of select="pg_from _hostdoc"/>
    </first_page">
    <volume>
    <xsl:value-of select="vol_fro m_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
    New Member
    • Jun 2008
    • 8

    #2
    My last xslt :


    <?xml version="1.0"?>
    <xsl:styleshe et 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:attribut e name="xsi:noNam espaceSchemaLoc ation">npldoc v2.0.xsd</xsl:attribute>
    <xsl:attribut e name="rundate"> 20080123</xsl:attribute>
    <xsl:for-each select="nplbibl io/document">
    <document status="n">
    <xsl:attribut e 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="supplie r"/>

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

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

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

    <first_page>
    <xsl:value-of select="documen t/attribs/attrib name=pg_from_ho stdoc"/>
    </first_page>

    <volume>
    <xsl:value-of select="documen t/attribs/attrib name=vol_from_h ostdoc"/>
    </volume>

    <issue>
    <xsl:value-of select="documen t/attribs/attrib name=nr_from_ho stdoc"/>
    </issue>

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

    Comment

    Working...