XLST - Help needed to write the XSL

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

    XLST - Help needed to write the XSL

    Hi,

    I want to create a .XSL to transform a XML document like below :


    ?xml version="1.0" encoding="ISO-8859-1" standalone="yes "?>

    <nplbiblio >

    <document >
    <xp>XP000571793 </xp>
    <doi>10.1117/12.205299</doi>
    </document >

    <document >
    <xp>XP000571816 </xp>
    <doi>10.1117/12.171773</doi>
    </document >

    </nplbiblio>



    into


    <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
    <!DOCTYPE nplbiblio SYSTEM "npl-entities.dtd">
    <nplbiblio xmlns:npl="http ://www.epo.org/npl" xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance" xsi:noNamespace SchemaLocation= "npldoc v2.0.xsd" rundate="200801 23" filename="AIP_4 3.xml">

    <document creadate="20080 523" status="N">
    <xp>XP000571793 </xp>
    <attribs>
    <attrib name="doi-art">10.1117/12.20529</attrib>
    </attribs>
    </document>

    <document creadate="20080 523" status="N">
    <xp>XP000571816 </xp>
    <attribs>
    <attrib name="doi-art">10.1117/12.171779</attrib>
    </attribs>
    </document>

    </nplbiblio>



    Can someone help me ?

    I have tried different writting different xsl with no success...

    Many thanks

    Sarah
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    Can you post the sample of your xsl so far? It might just be something really simple you're getting caught up on.

    Comment

    • sarah12
      New Member
      • Jun 2008
      • 8

      #3
      <?xml version='1.0' ?>
      <xsl:styleshe et version="1.0" xmlns:xsl="http ://www.w3.org/1999/XSL/Transform" >
      <xsl:template match="/">

      <nplbiblio>

      <xsl:for-each select="a:nplbi blio/a:document">
      <document status="n">
      <xp>
      <xsl:value-of select="a:xp"/>
      </xp>

      <attribs>
      <attrib name="doi-art">
      <xsl:value-of select="a:doi"/>
      </attrib>
      </attribs>

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

      Comment

      • sarah12
        New Member
        • Jun 2008
        • 8

        #4
        Thanks for the help ! I am not a XML expert and trying my best ...;}

        Comment

        • jkmyoung
          Recognized Expert Top Contributor
          • Mar 2006
          • 2057

          #5
          Note the use of <xsl:output/>, the declaration of other namespaces, and the use of <xsl:copy-of/>
          [code=xml]
          <?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"/>
          <attribs>
          <attrib name="doi-art">
          <xsl:value-of select="doi"/>
          </attrib>
          </attribs>
          </document>
          </xsl:for-each>
          </nplbiblio>
          </xsl:template>
          </xsl:stylesheet>
          [/code]

          Comment

          • sarah12
            New Member
            • Jun 2008
            • 8

            #6
            A million thanks ... I was indeed a bit far off !

            I am currently studying closer the difference between "<xsl:copy-of> and <xsl:cvalue-of>.

            Still learning ....

            Comment

            Working...