Connecting Tech Pros Worldwide Help | Site Map

XLST - Help needed to write the XSL

 
LinkBack Thread Tools Search this Thread
  #1  
Old June 24th, 2008, 11:39 AM
Newbie
 
Join Date: Jun 2008
Posts: 8
Default 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: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
Reply
  #2  
Old June 24th, 2008, 03:14 PM
Moderator
 
Join Date: Mar 2006
Posts: 1,096
Default

Can you post the sample of your xsl so far? It might just be something really simple you're getting caught up on.
Reply
  #3  
Old June 25th, 2008, 06:51 AM
Newbie
 
Join Date: Jun 2008
Posts: 8
Default

<?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
  #4  
Old June 25th, 2008, 06:52 AM
Newbie
 
Join Date: Jun 2008
Posts: 8
Default

Thanks for the help ! I am not a XML expert and trying my best ...;}
Reply
  #5  
Old June 26th, 2008, 07:44 PM
Moderator
 
Join Date: Mar 2006
Posts: 1,096
Default

Note the use of <xsl:output/>, the declaration of other namespaces, and the use of <xsl:copy-of/>
Expand|Select|Wrap|Line Numbers
  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>
  22.  
Reply
  #6  
Old June 27th, 2008, 07:47 AM
Newbie
 
Join Date: Jun 2008
Posts: 8
Default

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

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search


Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.