Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 16th, 2011, 11:50 AM
Registered User
Join Date: Feb 2011
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Field content prefixes in output xml?


I am a complete newcomer to both these forums and to xslt. I work with library metadata. In fact, I am trying to figure out if an xslt stylesheet can solve my xml conversion problems. If so, I will work on learning enough xslt to hack an existing sheet. I apologize if this question is basic or obvious, but I am only self- taught in programing, so I don't have the world's best theoretical background.

I need to convert MARC xml into OAI-DC xml. If these mean nothing to you, just think of them as xml1 and xml2. Then I will feed xml2 into a pre-existing database. I cannot touch the database coding (the server is not in my direct control). Nor can I change the creation of the xml1 file. I want to use a xslt stylesheet to add prefixes and suffixes to the CONTENT of the data fields in xml1. I am not talking about namespace prefixes. Can I use xslt to do this? or do I need to look at Xpath?

For example, I have existing records:


I want as an output:
<a2>Title: Patton</a2>
<b2><a href="URL">URL</a></b2>
I will use the reference entities for [<a href="URL">URL</a>].

Should this work? Either the first transformation or the second, using html tags? I know that the solution is not elegant. However, I am working with large amount of records, some in proprietary databases. I can't even directly fool with the eventual web-page code, it all has to go through an interface which can only bulk upload record field data. Such is the world of libraries.

Thanks for any help you can give,
Old February 16th, 2011, 11:57 AM
Friend of Wrox
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts

<xsl:template match="a1">
    <xsl:text>Title: </xsl:text>
should do for the 'a1' elements.
<xsl:template match="b1">
    <a href="{.}">
should do for the 'b1' elements.
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
Old February 16th, 2011, 12:07 PM
Registered User
Join Date: Feb 2011
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Thanks!

Thank you so much. I appreciate not only the answer (that it could be done) but the code. I should be able to integrate these fixes into the xslt sheet without much difficulty. And I am very happy that I haven't been wasting my work time with xslt!

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to output the entire content to a string sunnyman XML 6 November 29th, 2007 10:48 PM
XML problems - prefixes and asp.net supergirl_gem XSLT 7 July 3rd, 2007 01:56 AM
Output existing value to new field Neal SQL Server 2000 5 March 12th, 2007 09:51 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.