Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 4370 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hello,

 

I'd be very grateful for a pointer on this, I'm new to XML and have to import files as supplied:

 

<?xml version="1.0" encoding="UTF-8"  standalone="yes" ?>
<object_desc>
	<main_desc>
		<ident>63859</ident>
		<modificationdate>14/10/2011</modificationdate>
		...
		<remark>This is a test</remark>
		<title>Property tile</title>
	</main_desc>
	<iptc>
		<bylinetitle></bylinetitle>
		<captionwriter></captionwriter>
		...
		<modifieddate></modifieddate>
		<source></source>
	</iptc>
	<extended_desc>
		<date_amended></date_amended>
		<library_id>177</library_id>
		...
		<filed_under>Masters Box</filed_under>
		<id_objet>Object</id_objet>
	</extended_desc>
		<keywords>HighResRestricted | permission required | Cheshire</keywords>
</object_desc>

 

Each file contains a single record but the data has been split into 'main_desc', 'iptc', 'extended_desc' and oddly 'keywords' just in the root.

 

I have created an xsl file as:

 

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>
	<xsl:template match="/">
		<FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult">
			<ERRORCODE>0</ERRORCODE>
			<PRODUCT BUILD="" NAME="" VERSION=""/>
			<DATABASE DATEFORMAT="" LAYOUT="" NAME="" RECORDS="" TIMEFORMAT=""/>
			<METADATA>
				<FIELD NAME="ident" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/>
				<FIELD NAME="modificationdate" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/>
				<FIELD NAME="remark" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/>
				<FIELD NAME="title" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/>
				<FIELD NAME="bylinetitle" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/>
				<FIELD NAME="captionwriter" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/>
				<FIELD NAME="modifieddate" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/>
				<FIELD NAME="source" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/>
				<FIELD NAME="date_amended" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/>
				<FIELD NAME="library_id" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/>
				<FIELD NAME="filed_under" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/>
				<FIELD NAME="id_objet" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/>
				<FIELD NAME="keywords" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/>
			</METADATA>
			<RESULTSET FOUND="">
				<xsl:for-each select="/object_desc/main_desc">
					<ROW MODID="" RECORDID="">
						<COL><DATA><xsl:value-of select="ident"/></DATA></COL>
						<COL><DATA><xsl:value-of select="modificationdate"/></DATA></COL>
						<COL><DATA><xsl:value-of select="remark"/></DATA></COL>
						<COL><DATA><xsl:value-of select="title"/></DATA></COL>
						<COL><DATA><xsl:value-of select="bylinetitle"/></DATA></COL>
						<COL><DATA><xsl:value-of select="captionwriter"/></DATA></COL>
						<COL><DATA><xsl:value-of select="modifieddate"/></DATA></COL>
						<COL><DATA><xsl:value-of select="source"/></DATA></COL>
						<COL><DATA><xsl:value-of select="date_amended"/></DATA></COL>
						<COL><DATA><xsl:value-of select="library_id"/></DATA></COL>
						<COL><DATA><xsl:value-of select="filed_under"/></DATA></COL>
						<COL><DATA><xsl:value-of select="id_objet"/></DATA></COL>
						<COL><DATA><xsl:value-of select="keywords"/></DATA></COL>
					</ROW>
				</xsl:for-each>
			</RESULTSET>
		</FMPXMLRESULT>
	</xsl:template>
</xsl:stylesheet>

 

But can only find a way for getting one section of the data in with '<xsl:for-each select="/object_desc/main_desc">' - is there a way to solve this with the XSL file?

 

Many thanks for taking the time to read this.

 

R

Posted

from what I read just add a 

 

 

<xsl:for-each select="/object_desc/iptc"> 

 


with the rest after the first </xsl:for-each>

 

and the 

 

<xsl:for-each select="/object_desc/extended_desc">

after that.

 

HTH

Posted

Thanks for responding, I tried that (and <xsl:for-each select="/object_desc/main_desc | /object_desc/iptc | /object_desc/extended_desc"> ) and get multiple rows for each file (object_desc), is there a way of stuffing 'main_desc', 'iptc', 'extended_desc' and 'keywords' all in to a single record? I've found similar requests by googling but have still not seen a solution except by going back to the XML file

 

Cheers

R

Posted

It's difficult to understand your request because the XML example is missing some parts - and it's not clear how representative this single example is. Try the following guess:

 

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>
    <xsl:template match="/">
        <FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult">
            <ERRORCODE>0</ERRORCODE>
            <PRODUCT BUILD="" NAME="" VERSION=""/>
            <DATABASE DATEFORMAT="" LAYOUT="" NAME="" RECORDS="" TIMEFORMAT=""/>
            <METADATA>
                <FIELD NAME="ident" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/>
                <FIELD NAME="modificationdate" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/>
                <FIELD NAME="remark" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/>
                <FIELD NAME="title" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/>
                <FIELD NAME="bylinetitle" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/>
                <FIELD NAME="captionwriter" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/>
                <FIELD NAME="modifieddate" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/>
                <FIELD NAME="source" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/>
                <FIELD NAME="date_amended" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/>
                <FIELD NAME="library_id" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/>
                <FIELD NAME="filed_under" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/>
                <FIELD NAME="id_objet" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/>
                <FIELD NAME="keywords" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/>
            </METADATA>
            <RESULTSET FOUND="">
                <xsl:for-each select="object_desc">
                    <ROW MODID="" RECORDID="">
                        <COL><DATA><xsl:value-of select="main_desc/ident"/></DATA></COL>
                        <COL><DATA><xsl:value-of select="main_desc/modificationdate"/></DATA></COL>
                        <COL><DATA><xsl:value-of select="main_desc/remark"/></DATA></COL>
                        <COL><DATA><xsl:value-of select="main_desc/title"/></DATA></COL>
                        <COL><DATA><xsl:value-of select="iptc/bylinetitle"/></DATA></COL>
                        <COL><DATA><xsl:value-of select="iptc/captionwriter"/></DATA></COL>
                        <COL><DATA><xsl:value-of select="iptc/modifieddate"/></DATA></COL>
                        <COL><DATA><xsl:value-of select="iptc/source"/></DATA></COL>
                        <COL><DATA><xsl:value-of select="extended_desc/date_amended"/></DATA></COL>
                        <COL><DATA><xsl:value-of select="extended_desc/library_id"/></DATA></COL>
                        <COL><DATA><xsl:value-of select="extended_desc/filed_under"/></DATA></COL>
                        <COL><DATA><xsl:value-of select="extended_desc/id_objet"/></DATA></COL>
                        <COL><DATA><xsl:value-of select="keywords"/></DATA></COL>
                    </ROW>
                </xsl:for-each>
            </RESULTSET>
        </FMPXMLRESULT>
    </xsl:template>
</xsl:stylesheet>
Posted

That worked a treat, thank you for your help, you've often provided answers on here that have helped me in the past too - just to let you that we appreciate what you do!

 

Cheers

R

This topic is 4370 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.