|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
sorry to say, but all wrong
<xsl:attribute name="AttributeName"> <xsl:value-of select="..."/> </xsl:attribute> Quote:
|
|
#3
|
|||
|
|||
|
Thanks
Thanks a lot that worked!
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > Newbie. XML to XML: with XSL - how to set arributes |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|