XLST - Help needed to write the XSL 
June 24th, 2008, 11:39 AM
| | Newbie | | Join Date: Jun 2008
Posts: 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: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
| 
June 24th, 2008, 03:14 PM
| | Moderator | | Join Date: Mar 2006
Posts: 1,096
| |
Can you post the sample of your xsl so far? It might just be something really simple you're getting caught up on.
| 
June 25th, 2008, 06:51 AM
| | Newbie | | Join Date: Jun 2008
Posts: 8
| |
<?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>
| 
June 25th, 2008, 06:52 AM
| | Newbie | | Join Date: Jun 2008
Posts: 8
| |
Thanks for the help ! I am not a XML expert and trying my best ...;}
| 
June 26th, 2008, 07:44 PM
| | Moderator | | Join Date: Mar 2006
Posts: 1,096
| |
Note the use of <xsl:output/>, the declaration of other namespaces, and the use of <xsl:copy-of/> -
<?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"/>
-
<attribs>
-
<attrib name="doi-art">
-
<xsl:value-of select="doi"/>
-
</attrib>
-
</attribs>
-
</document>
-
</xsl:for-each>
-
</nplbiblio>
-
</xsl:template>
-
</xsl:stylesheet>
-
| 
June 27th, 2008, 07:47 AM
| | Newbie | | Join Date: Jun 2008
Posts: 8
| |
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 ....
|  | | Thread Tools | Search this Thread | | | | | | | 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.
|