XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 10th, 2004, 01:42 PM
whitbyterry whitbyterry is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Toronto, Canada
Posts: 1 whitbyterry User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question XSLT Help

Hello

I am trying to transform an XML document (the source is from Lotus Notes so it is actually "DXL").

I have a particular xml field/entry that contains URLs. I want to use my existing XSLT to transform SOME of the URLS (based on a pattern) into different URLs.

Example:
In the source document there is this URL:

http://someserver.company.com/folder/database.nsf/idnum/20040293939393or
http://someserver.company.com/folder/database.nsf/idnum/20040293939393?open&someparmemter=somevalue


All the URLS that I want to transform are basically the same structure but what I need to do is to extract the value after the "/idnum/" and ending with a termination of the URL or when the "?" appears and then REPLACE the URL with a new one.

The links can appear just as text or they can actual 'links' in the field.

Here is a sample XSLT statement within an entire XSLT:

<Solution><xsl:choose><xsl:when test="//dxl:item[@name='Solution']/dxl:richtext"><xsl:copy-of select="//dxl:item[@name='Solution']/dxl:richtext"/></xsl:when><xsl:otherwise><richtext xmlns="http://www.lotus.com/dxl"/></xsl:otherwise></xsl:choose></Solution>


Is there a way within this statement to write a transformation that will search through this field, locate the proper pattern and extract out the "number" I want so I could then construct a new URL:

http://newserver.somecompany.com/docx/20040293939393.jsp

a) is this possible?
b) how do you do it?

Note - my transformation currently works perfectly so please go on the assumption that namespaces and other items in the XSLT are working.

Thanks
Terry

Reply With Quote
  #2  
Old March 11th, 2004, 07:12 AM
MattSidesinger's Avatar
MattSidesinger MattSidesinger is offline
Java PHP Oracle Developer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: C-Bus OH-IO
Posts: 204 MattSidesinger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 26 sec
Reputation Power: 5
Send a message via AIM to MattSidesinger
It is possible, I am working on it now.

Reply With Quote
  #3  
Old March 11th, 2004, 07:26 AM
MattSidesinger's Avatar
MattSidesinger MattSidesinger is offline
Java PHP Oracle Developer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: C-Bus OH-IO
Posts: 204 MattSidesinger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 26 sec
Reputation Power: 5
Send a message via AIM to MattSidesinger
This is the XSL template used to extract a portion of a link:
Code:
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:template match="/">
	<xsl:for-each select="rootNode/link">
		<xsl:call-template name="extractNumberFromLink">
			<xsl:with-param name="link" select="."/>
		</xsl:call-template>
	</xsl:for-each>
</xsl:template>

<xsl:template name="extractNumberFromLink">
	<xsl:param name="link"/>

	<xsl:variable name="COMES_AFTER" select="'/idnum/'"/>
	<xsl:variable name="COMES_BEFORE" select="'?'"/>
	
	<xsl:variable name="result" select="substring-after($link, $COMES_AFTER)"/>
	<xsl:choose>
		<xsl:when test="contains($result, $COMES_BEFORE)">
			<xsl:value-of select="substring-before($result, $COMES_BEFORE)"/>
		</xsl:when>
		<xsl:otherwise>
			<xsl:value-of select="$result"/>
		</xsl:otherwise>
	</xsl:choose>
	
</xsl:template>

</xsl:stylesheet>


Test XML:
Code:
<?xml version="1.0"?>
<rootNode>
	<link>http://someserver.company.com/folder/database.nsf/idnum/20040293939393or</link>
<link>http://someserver.company.com/folder/database.nsf/idnum/20040293939393?open&someparmemter=somevalue</link>
</rootNode>


You should probably read the spec or read about all of the standard functions of XSL before continue using it.
http://www.w3c.org

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > XSLT Help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT