473,396 Members | 2,115 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

XLST - Help needed to write the XSL (2)

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">
<xp>000000028876</xp>
<doctype>ABSTRACT</doctype>
<prdate>19880131</prdate>
<ord>19880131</ord>
<titles>
<title> CREEP BEHAVIOR OF GLASS FIBER-REINFORCED HARDBOARD.</title>
</titles>
<author>SMULSKI S. J., IFJU G.</author>
<supplier>MIGRATION</supplier>
<attribs>
<attrib name="nr_hostdoc">07</attrib>
<attrib name="pg_abs">940</attrib>
<attrib name="vol_hostdoc">58</attrib>
</attribs>
<publication>
<pubtitle>ABSTRACT BULLETIN OF THE INSTITUTE OF PAPER CHEMISTRY.</pubtitle>
<pubname>THE INSTITUTE OF PAPER CHEMISTRY-LIBRARY. APPLETON.</pubname>
<pubaddr>US</pubaddr>
<pubattr>
<attrib name="magno_hostdoc">0005500</attrib>
<attrib name="vnum_hostdoc">1004</attrib>
</pubattr>
</publication>
</document>
</nplbiblio>



into :

<?xml version="1.0" ?>
<nplbiblio rundate="20080110">
<document status="U" creadate="19990410">
<xp>000000028876</xp>
<doctype>ABSTRACT</doctype>
<prdate>19880131</prdate>
<ord>19880131</ord>

<title language=" ">CREEP BEHAVIOR OF GLASS FIBER-REINFORCED HARDBOARD.</title>

<author>SMULSKI S. J., IFJU G.</author>
<supplier>MIGRATION</supplier>

<issue>07</issue>
<first_page> 940.</first_page>
<volume>58</volume>

<pubtitle>ABSTRACT BULLETIN OF THE INSTITUTE OF PAPER CHEMISTRY.</pubtitle>

<pubname>THE INSTITUTE OF PAPER CHEMISTRY-LIBRARY. APPLETON.</pubname>

<pubaddr>US</pubaddr>

</document>
</nplbiblio>


The transformations required is to :
- Extract only some specific tags and their data
- Make some sub level tags as main level tags
- Change the name of some tags

Can you help ?

I have written this xlst :


<?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"/>
<xsl:copy-of select="doctype"/>
<xsl:copy-of select="prdate"/>
<xsl:copy-of select="xp"/>
<xsl:copy-of select="author"/>
<xsl:copy-of select="supplier"/>

<title>
<xsl:value-of select="title"/>
</title>

<first_page">
<xsl:value-of select="pg_from_hostdoc"/>
</first_page">
<volume>
<xsl:value-of select="vol_from_hostdoc"/>
</volume>
<issue>
<xsl:value-of select="nr_from_hostdoc"/>
</issue>
<issn>
<xsl:value-of select="issn"/>
</issn>

<isbn>
<xsl:value-of select="isbn"/>
</isbn>

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


But I keep getting errors....
Jun 27 '08 #1
1 1691
My last xslt :


<?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"/>
<xsl:copy-of select="doctype"/>
<xsl:copy-of select="prdate"/>
<xsl:copy-of select="xp"/>
<xsl:copy-of select="author"/>
<xsl:copy-of select="supplier"/>

<title>
<xsl:value-of select="document/titles/title"/>
</title>

<isbn>
<xsl:value-of select="document/publication/irn/isbn"/>
</isbn>

<issn>
<xsl:value-of select="document/publication/irn/issn"/>
</issn>

<first_page>
<xsl:value-of select="document/attribs/attrib name=pg_from_hostdoc"/>
</first_page>

<volume>
<xsl:value-of select="document/attribs/attrib name=vol_from_hostdoc"/>
</volume>

<issue>
<xsl:value-of select="document/attribs/attrib name=nr_from_hostdoc"/>
</issue>

</document>
</xsl:for-each>
</nplbiblio>
</xsl:template>
</xsl:stylesheet>
Jun 27 '08 #2

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. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
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...

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.