Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

XLST - Help needed to write the XSL

Question posted by: sarah12 (Newbie) on June 24th, 2008 11:39 AM
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:noNamespaceSchemaLocation="npldoc v2.0.xsd" rundate="20080123" filename="AIP_43.xml">

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

<document creadate="20080523" 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
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
jkmyoung's Avatar
jkmyoung
Moderator
765 Posts
June 24th, 2008
03:14 PM
#2

Re: XLST - Help needed to write the XSL
Can you post the sample of your xsl so far? It might just be something really simple you're getting caught up on.

Reply
sarah12's Avatar
sarah12
Newbie
8 Posts
June 25th, 2008
06:51 AM
#3

Re: XLST - Help needed to write the XSL
<?xml version='1.0' ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:template match="/">

<nplbiblio>

<xsl:for-each select="a:nplbiblio/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>

Reply
sarah12's Avatar
sarah12
Newbie
8 Posts
June 25th, 2008
06:52 AM
#4

Re: XLST - Help needed to write the XSL
Thanks for the help ! I am not a XML expert and trying my best ...;}

Reply
jkmyoung's Avatar
jkmyoung
Moderator
765 Posts
June 26th, 2008
07:44 PM
#5

Re: XLST - Help needed to write the XSL
Note the use of <xsl:output/>, the declaration of other namespaces, and the use of <xsl:copy-of/>
Code: ( text )
  1. <?xml version="1.0"?>
  2. <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">
  3.     <xsl:output method="xml" doctype-system="npl-entities.dtd"/>
  4.     <xsl:template match="/">
  5.         <nplbiblio>
  6.             <xsl:attribute name="xsi:noNamespaceSchemaLocation">npldoc v2.0.xsd</xsl:attribute>
  7.             <xsl:attribute name="rundate">20080123</xsl:attribute>
  8.             <xsl:for-each select="nplbiblio/document">
  9.                 <document status="n">
  10.                     <xsl:attribute name="creadate">20080123</xsl:attribute>
  11.                     <xsl:copy-of select="xp"/>
  12.                     <attribs>
  13.                         <attrib name="doi-art">
  14.                             <xsl:value-of select="doi"/>
  15.                         </attrib>
  16.                     </attribs>
  17.                 </document>
  18.             </xsl:for-each>
  19.         </nplbiblio>
  20.     </xsl:template>
  21. </xsl:stylesheet>

Reply
sarah12's Avatar
sarah12
Newbie
8 Posts
June 27th, 2008
07:47 AM
#6

Re: XLST - Help needed to write the XSL
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 ....

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

Top XML Forum Contributors