Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 16th, 2011, 11:50 AM
Registered User
Points: 20, Level: 1
Points: 20, Level: 1 Points: 20, Level: 1 Points: 20, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2011
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Field content prefixes in output xml?

Hello!

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:

<a1>Patton</a1>
<b1>URL</b1>

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,
CAMc
Reply With Quote
  #2 (permalink)  
Old February 16th, 2011, 11:57 AM
Friend of Wrox
Points: 6,676, Level: 34
Points: 6,676, Level: 34 Points: 6,676, Level: 34 Points: 6,676, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2007
Location: Germany
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Code:
<xsl:template match="a1">
  <a2>
    <xsl:text>Title: </xsl:text>
    <xsl:apply-templates/>
  </a2>
</xsl:template>
should do for the 'a1' elements.
Code:
<xsl:template match="b1">
  <b2>
    <a href="{.}">
      <xsl:apply-templates/>
    </a>
  </b2>
</xsl:template>
should do for the 'b1' elements.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
Reply With Quote
  #3 (permalink)  
Old February 16th, 2011, 12:07 PM
Registered User
Points: 20, Level: 1
Points: 20, Level: 1 Points: 20, Level: 1 Points: 20, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 10:54 PM.


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