Jump to content

xsl Attribute issue


Devin

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

Recommended Posts

I've got a simple ( I hope) export as xml issue

Here is my current .xsl that is erroring.. My issue is Line 9.. I'm not sure how I need modify the Attribute of Pages?

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fmp="http://www.filemaker.com/fmpxmlresult" xmlns:xalan="http://xml.apache.org/xalan" version="1.0" exclude-result-prefixes="fmp xalan">
	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" xalan:indent-amount="2"/>
	<xsl:template match="/">
		<JDF xmlns="http://www.CIP4.org/JDFschema_1_1" Status="Ready" Type="ProcessGroup" Version="1.2">
			<ResourcePool>
				<RunList Class="Parameter" ID="Link1" Locked="false" PartIDKeys="Run" Status="Available">
					<xsl:for-each select="fmp:FMPXMLRESULT/fmp:RESULTSET/fmp:ROW">
						<RunList Class="Parameter" Pages="<xsl:value-of select="fmp:COL[3]/fmp:DATA"/>" Run="1">
							<LayoutElement>
								<FileSpec URL="file://%2a.pdf"/>
							</LayoutElement>
						</RunList>
					</xsl:for-each>
				</RunList>
			</ResourcePool>
			<ResourceLinkPool>
				<RunListLink Usage="Input" rRef="Link1"/>
			</ResourceLinkPool>
		</JDF>
	</xsl:template>
</xsl:stylesheet>

 

Here is an example of what I want to see when I export..  The only real part that changes is the "Pages=" part.

<?xml version = "1.0" ?>
<JDF Status="Ready" Type="ProcessGroup" Version="1.2" xmlns="http://www.CIP4.org/JDFschema_1_1">
	<ResourcePool>
		<RunList Class="Parameter" ID="Link1" Locked="false" PartIDKeys="Run" Status="Available">
			<RunList Class="Parameter" Pages="7" Run="1">
				<LayoutElement>
					<FileSpec URL="file://%2a.pdf"/>
				</LayoutElement>
			</RunList>
			<RunList Class="Parameter" Pages="8" Run="1">
				<LayoutElement>
					<FileSpec URL="file://%2a.pdf"/>
				</LayoutElement>
			</RunList>
			<RunList Class="Parameter" Pages="9" Run="1">
				<LayoutElement>
					<FileSpec URL="file://%2a.pdf"/>
				</LayoutElement>
			</RunList>
			<RunList Class="Parameter" Pages="9" Run="1">
				<LayoutElement>
					<FileSpec URL="file://%2a.pdf"/>
				</LayoutElement>
			</RunList>
			<RunList Class="Parameter" Pages="10" Run="1">
				<LayoutElement>
					<FileSpec URL="file://%2a.pdf"/>
				</LayoutElement>
			</RunList>
			<RunList Class="Parameter" Pages="10" Run="1">
				<LayoutElement>
					<FileSpec URL="file://%2a.pdf"/>
				</LayoutElement>
			</RunList>
			<RunList Class="Parameter" Pages="0" Run="1">
				<LayoutElement>
					<FileSpec URL="file://%2a.pdf"/>
				</LayoutElement>
			</RunList>
		</RunList>
	</ResourcePool>
	<ResourceLinkPool>
		<RunListLink Usage="Input" rRef="Link1"/>
	</ResourceLinkPool>
</JDF>

 

Link to comment
Share on other sites

Please also add an example: file.fmpxmlresult.xml file.

 

<xsl:template match="fmp:FMPXMLRESULT/fmp:RESULTSET/fmp:ROW">
  <RunList Class="Parameter" Run="1">
    <xsl:attribute name="Pages">
        <xsl:value-of select="fmp:COL[3]/fmp:DATA"/>
    </xsl:attribute>
    <LayoutElement>
      <FileSpec URL="file://%2a.pdf"/>
    </LayoutElement>
  </RunList>
</xsl:template>

<RunList Class="Parameter" ID="Link1" Locked="false" PartIDKeys="Run" Status="Available">
  <xsl:apply-templates select="fmp:FMPXMLRESULT/fmp:RESULTSET/fmp:ROW"/>
</RunList>

How many records are you working with? Template usually spends less memory than for-each

Edited by ggt667
Link to comment
Share on other sites

If I am guessing correctly, instead of: 

<RunList Class="Parameter" Pages="<xsl:value-of select="fmp:COL[3]/fmp:DATA"/>" Run="1">

you want to do:

<RunList Class="Parameter" Pages="{fmp:COL[3]/fmp:DATA}" Run="1">

For explanation of this syntax, see: https://www.w3.org/TR/1999/REC-xslt-19991116#attribute-value-templates

 

Alternatively, you can use the more verbose:

<RunList Class="Parameter" Run="1">
    <xsl:attribute name="Pages">
        <xsl:value-of select="fmp:COL[3]/fmp:DATA"/>
    </xsl:attribute>

 

 

Link to comment
Share on other sites

This topic is 1877 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.