473,466 Members | 1,351 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

XLST - Help needed to write the XSL

8 New Member
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
Jun 24 '08 #1
5 2070
jkmyoung
2,057 Recognized Expert Top Contributor
Can you post the sample of your xsl so far? It might just be something really simple you're getting caught up on.
Jun 24 '08 #2
sarah12
8 New Member
<?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>
Jun 25 '08 #3
sarah12
8 New Member
Thanks for the help ! I am not a XML expert and trying my best ...;}
Jun 25 '08 #4
jkmyoung
2,057 Recognized Expert Top Contributor
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.  
Jun 26 '08 #5
sarah12
8 New Member
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 ....
Jun 27 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Pascal Sartoretti | last post by:
Hello, I am looking for a formal definition of XSLT. Either a DTD or an XML Schema, whatever. Is there such a thing ? There is for instance one for XML Schema itself at...
1
by: Vital Lobachevsky | last post by:
Hi! I'm absolutely newbie with XSLT. Please, help me with this example. I have simple XML document like this: <skip /> <aaa> <link url="url1" /> <link url="url2" />
3
by: Greg Jones | last post by:
Hello, This may be a simple question but difficult to search on since the keywords are so generic. Is there a way, in XSLT, to copy an embedded DTD from the source XML to the target XML?...
3
by: Hai Nguyen | last post by:
I would like to know after transforming my datatables which store in dataset into XML form. Now I want to save it into a file and also create a XLST file to read it. How can I do that? Would you...
3
by: Hai Nguyen | last post by:
Sorry I don't have code yet. I'm asking for solutions which can help me solve the problem. This is the first time I have to cope this situation, hence I'm clueless how to start. I would like to ask...
1
by: Adrian | last post by:
Hi No sure if xlst is the correct choice! or if it is how I would use it from within a windows VB application! I had XML data help in an xmlelements object and I want to format the data and...
1
by: ad | last post by:
Hi, How can I use xlst to display a xml file in asp.net?
5
by: MD | last post by:
my database return the search result in the xml. I have about 100 fields with 10 records if i use the dom to parse in the browser with javascript takes about 30 seconds to generate the table with...
1
by: dave_kajinsky | last post by:
Hello all, I would like to do something with xlst, perhaps I can get help from this group? Here it goes: I've got 2 files: an ascii file and a file that identifies tokens in the ascii file. ...
1
by: sarah12 | last post by:
HI, This time , I need to write the XSL to transform the following document : <?xml version="1.0"?> <nplbiblio rundate="20080110"> <document status="U" creadate="19990410">...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.