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 August 22nd, 2004, 03:31 PM
mark_anderson_u mark_anderson_u is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 2 mark_anderson_u User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Newbie. XML to XML: with XSL - how to set arributes

Hi all

I wonder if you can help me with a problem. I'm getting an XML fiel from a database (FileMaker Pro). druing export, I can select an XSL file to transform the xml format I actually need. I can'f figure out how to set the attributes in the target XMl.

here is the source XML

<?xml version="1.0" encoding="UTF-8" ?>
- <FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult">
<ERRORCODE>0</ERRORCODE>
<PRODUCT BUILD="05-06-2004" NAME="FileMaker Pro" VERSION="7.0v2" />
<DATABASE DATEFORMAT="D/m/yyyy" LAYOUT="" NAME="test.fp7" RECORDS="1" TIMEFORMAT="k:mm:ss" />
- <METADATA>
<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="JobNumber" TYPE="NUMBER" />
<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="JobName" TYPE="TEXT" />
<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="CustomerID" TYPE="NUMBER" />
<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="CustomerName" TYPE="TEXT" />
</METADATA>
- <RESULTSET FOUND="1">
- <ROW MODID="2" RECORDID="1">
- <COL>
<DATA>12345</DATA>
</COL>
- <COL>
<DATA>8 page brochure</DATA>
</COL>
- <COL>
<DATA>FolioPublishing</DATA>
</COL>
- <COL>
<DATA />
</COL>
</ROW>
</RESULTSET>
</FMPXMLRESULT>

I need to get at the contents of the columns and use the data as attributes in the new XML: (here I want the contents of COL[2] ("8 page brochure") in the descriptive name field

<?xml version="1.0" encoding="UTF-8" ?>
<jdf:JDF ID="NodeId1" Status="Ready" Category="PrePress" Type="ProcessGroup" JobID="2004081823361610" JobPartID="Body" DescriptiveName="8 page brochure">
</jdf:JDF>


Here is what I figured I need to do (but the syntax is illegal)

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="fmp:FMPXMLRESULT">
<xsl:for-each select="fmp:RESULTSET/fmp:ROW">
<p><xsl:value-of select="fmp:COL[2]/fmp:DATA" /></p> <-- This is just to check I'm getting value -->
<jdf:JDF ID="NodeId1" Status="Ready" Category="PrePress" Type="ProcessGroup" JobID="2004081823361610" JobPartID="Body" DescriptiveName="<xsl:value-of select="fmp:COL[2]/fmp:DATA" />" >
</jdf:JDF>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

Can someone help me with the syntax, or am I going about it completely wrong?

TIA

mark

Reply With Quote
  #2  
Old August 22nd, 2004, 08:06 PM
Zero-x252 Zero-x252 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Location: Colorado
Posts: 61 Zero-x252 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 54 m 22 sec
Reputation Power: 5
Send a message via AIM to Zero-x252 Send a message via MSN to Zero-x252 Send a message via Yahoo to Zero-x252
sorry to say, but all wrong
<xsl:attribute name="AttributeName">
<xsl:value-of select="..."/>
</xsl:attribute>
Quote:
Originally Posted by mark_anderson_u
Hi all

I wonder if you can help me with a problem. I'm getting an XML fiel from a database (FileMaker Pro). druing export, I can select an XSL file to transform the xml format I actually need. I can'f figure out how to set the attributes in the target XMl.

here is the source XML

<?xml version="1.0" encoding="UTF-8" ?>
- <FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult">
<ERRORCODE>0</ERRORCODE>
<PRODUCT BUILD="05-06-2004" NAME="FileMaker Pro" VERSION="7.0v2" />
<DATABASE DATEFORMAT="D/m/yyyy" LAYOUT="" NAME="test.fp7" RECORDS="1" TIMEFORMAT="k:mm:ss" />
- <METADATA>
<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="JobNumber" TYPE="NUMBER" />
<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="JobName" TYPE="TEXT" />
<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="CustomerID" TYPE="NUMBER" />
<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="CustomerName" TYPE="TEXT" />
</METADATA>
- <RESULTSET FOUND="1">
- <ROW MODID="2" RECORDID="1">
- <COL>
<DATA>12345</DATA>
</COL>
- <COL>
<DATA>8 page brochure</DATA>
</COL>
- <COL>
<DATA>FolioPublishing</DATA>
</COL>
- <COL>
<DATA />
</COL>
</ROW>
</RESULTSET>
</FMPXMLRESULT>

I need to get at the contents of the columns and use the data as attributes in the new XML: (here I want the contents of COL[2] ("8 page brochure") in the descriptive name field

<?xml version="1.0" encoding="UTF-8" ?>
<jdf:JDF ID="NodeId1" Status="Ready" Category="PrePress" Type="ProcessGroup" JobID="2004081823361610" JobPartID="Body" DescriptiveName="8 page brochure">
</jdf:JDF>


Here is what I figured I need to do (but the syntax is illegal)

<xslutput method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="fmp:FMPXMLRESULT">
<xsl:for-each select="fmp:RESULTSET/fmp:ROW">
<p><xsl:value-of select="fmp:COL[2]/fmpATA" /></p> <-- This is just to check I'm getting value -->
<jdf:JDF ID="NodeId1" Status="Ready" Category="PrePress" Type="ProcessGroup" JobID="2004081823361610" JobPartID="Body" DescriptiveName="<xsl:value-of select="fmp:COL[2]/fmpATA" />" >
</jdf:JDF>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

Can someone help me with the syntax, or am I going about it completely wrong?

TIA

mark

Reply With Quote
  #3  
Old August 23rd, 2004, 02:02 AM
mark_anderson_u mark_anderson_u is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 2 mark_anderson_u User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks

Thanks a lot that worked!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Newbie. XML to XML: with XSL - how to set arributes


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

 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

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





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