Reputation: 2461
I'm using a for-each
in my XSLT
. In my example XML
I only have one element but the for-each is executing 13 times and I can't figure out why.
XSLT
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<rowset>
<xsl:for-each select="OUTPUT/eas:ShowDetailedRequestsByScheduleId/eas:ScheduleRequest">
<xsl:variable name="status"/>
<test>
<xsl:value-of select="@Schedule"/>
</test>
</xsl:for-each>
</rowset>
</xsl:template>
</xsl:stylesheet>
XML Input
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<OUTPUT xmlns:eas="****************">
<eas:ShowDetailedRequestsByScheduleId>
<eas:ScheduleRequest PPR="" Schedule="New Standard Drum Filling Orders" createdBy="" createdOn="2014-05-03 01:14:06.973" endTime="" isaDescription="" isaId="50527" lastModifiedBy="" lastModifiedOn="" priority="1" startTime="">
<eas:SegmentRequirement ScheduleRequest="50527" createdBy="root" createdOn="2014-05-03 01:14:06.973" duration="" durationUnitOfMeasure="" endTime="" isaDescription="" isaId="DF_FIlling" lastModifiedBy="root" lastModifiedOn="2014-05-03 01:14:06.973" startTime="">
<eas:MaterialProducedRequirement createdBy="root" createdOn="2014-05-03 01:14:06.977" isaDescription="" isaId="" lastModifiedBy="root" lastModifiedOn="2014-05-03 01:14:06.977" location="" materialDefinition="51014-302" quantity="5.000000000000" quantityUnitOfMeasure=""/>
</eas:SegmentRequirement>
</eas:ScheduleRequest>
</eas:ShowDetailedRequestsByScheduleId>
</OUTPUT>
XML Output
<?xml version="1.0" encoding="UTF-8"?>
<rowset>
<test />
<test />
<test />
<test />
<test>New Standard Drum Filling Orders</test>
<test />
<test />
<test />
<test />
<test />
<test />
<test />
<test />
</rowset>
Upvotes: 0
Views: 252
Reputation: 19482
The Namespace need to be defined in the XML and the XSLT, too. It is missing in the XSLT at the moment:
XSLT:
<?xml version="1.0" ?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:eas="****************">
<!-- ... --->
</xsl:stylesheet>
XML Input:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<OUTPUT xmlns:eas="****************">
<eas:ShowDetailedRequestsByScheduleId>
<!-- ... --->
</eas:ShowDetailedRequestsByScheduleId>
</OUTPUT>
Upvotes: 1