Project

Profile

Help

Inner for-each not being processed

Added by Anonymous about 17 years ago

Legacy ID: #4489052 Legacy Poster: Kristin (kholum)

I have some xsl code that is not being run because the inner for-each isn't being attempted - at least that is what it looks like. Basically, the xsl reads in diagram information concerning shapes, parallel lines and arrows and then generates a process flow diagram. Currently, a webpage is not being generated. If I add a '/' in front of the OBJECT element in the second for-each loop in the ARROWS.xls file, then a webpage will generate containing a flow diagram minus the arrow connectors. I have narrowed down the problem to a template call stored in another xsl file. When I perform a copy-of '.' right when I enter the first loop, then all the proper information displays. However, when I do the same after the second for-each, nothing is displayed. What am I missing? I am fairly new to xml, xsl and xpath and can't seem to find the problem. I have provided a small amount of code from each xls below. Can someone tell me if there is a limitation in xsl for number of times data can be manipulated in memory? Also, is there a limitation on nested if or when statements? ************************************************************************************* DIAGRAM.xsl <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:doc="urn:schemas-cagle-com:document" exclude-result-prefixes="doc"> <xsl:variable name="arrows" doc:description="Write Arrow objects for future processing"> <xsl:for-each select="$src/SHAPES"> <xsl:for-each select="descendant::ARROW"> <xsl:variable name="srowid"><xsl:value-of select="number(COORDINATES/START_ROW - 0.5)"/></xsl:variable> <xsl:variable name="erowid"><xsl:value-of select="number(COORDINATES/END_ROW + 0.5)"/></xsl:variable> <xsl:choose> <xsl:when test="VERT_LIMIT"> <LEVEL SROW="{COORDINATES/START_ROW}"> <OBJECT ID="{@ID}"> <xsl:copy-of select="SHAPE_TYPE"/> <xsl:copy-of select="COORDINATES/START_ROW"/> <xsl:copy-of select="COORDINATES/START_COLUMN"/> <xsl:copy-of select="COORDINATES/END_ROW"/> <xsl:copy-of select="COORDINATES/END_COLUMN"/> <ATYPE><xsl:value-of select="'S2'"/></ATYPE> <VERT_LIMIT><xsl:value-of select="VERT_LIMIT"/></VERT_LIMIT> <xsl:copy-of select="TEXT"/> </OBJECT> </LEVEL> </xsl:when> <xsl:when test="not(VERT_LIMIT) and COORDINATES/END_COLUMN != COORDINATES/START_COLUMN and COORDINATES/END_ROW != COORDINATES/START_ROW"> <LEVEL SROW="{COORDINATES/START_ROW}"> <OBJECT ID="{@ID}"> <xsl:copy-of select="SHAPE_TYPE"/> <xsl:copy-of select="COORDINATES/START_ROW"/> <xsl:copy-of select="COORDINATES/START_COLUMN"/> <xsl:copy-of select="COORDINATES/END_ROW"/> <xsl:copy-of select="COORDINATES/END_COLUMN"/> <ATYPE><xsl:value-of select="'S1'"/></ATYPE> <VERT_LIMIT></VERT_LIMIT> <xsl:copy-of select="TEXT"/> </OBJECT> </LEVEL> </xsl:when> <xsl:when test="not(VERT_LIMIT) and COORDINATES/END_COLUMN = COORDINATES/START_COLUMN and COORDINATES/END_ROW &gt; COORDINATES/START_ROW"> <LEVEL SROW="{COORDINATES/START_ROW}"> <OBJECT ID="{@ID}"> <xsl:copy-of select="SHAPE_TYPE"/> <xsl:copy-of select="COORDINATES/START_ROW"/> <xsl:copy-of select="COORDINATES/START_COLUMN"/> <xsl:copy-of select="COORDINATES/END_ROW"/> <xsl:copy-of select="COORDINATES/END_COLUMN"/> <ATYPE><xsl:value-of select="'D'"/></ATYPE> <VERT_LIMIT></VERT_LIMIT> <xsl:copy-of select="TEXT"/> </OBJECT> </LEVEL> </xsl:when> <xsl:when test="not(VERT_LIMIT) and COORDINATES/END_COLUMN = COORDINATES/START_COLUMN and COORDINATES/END_ROW &lt; COORDINATES/START_ROW"> <LEVEL SROW="{COORDINATES/END_ROW}"> <OBJECT ID="{@ID}"> <xsl:copy-of select="SHAPE_TYPE"/> <xsl:copy-of select="COORDINATES/END_ROW"/> <xsl:copy-of select="COORDINATES/START_COLUMN"/> <xsl:copy-of select="COORDINATES/START_ROW"/> <xsl:copy-of select="COORDINATES/END_COLUMN"/> <ATYPE><xsl:value-of select="'U'"/></ATYPE> <VERT_LIMIT></VERT_LIMIT> <xsl:copy-of select="TEXT"/> </OBJECT> </LEVEL> </xsl:when> <xsl:when test="not(VERT_LIMIT) and COORDINATES/END_COLUMN &gt; COORDINATES/START_COLUMN and COORDINATES/END_ROW = COORDINATES/START_ROW"> <LEVEL SROW="{$srowid}"> <OBJECT ID="{@ID}"> <xsl:copy-of select="SHAPE_TYPE"/> <START_ROW><xsl:value-of select="number($srowid)"/></START_ROW> <xsl:copy-of select="COORDINATES/START_COLUMN"/> <END_ROW><xsl:value-of select="number($erowid)"/></END_ROW> <xsl:copy-of select="COORDINATES/END_COLUMN"/> <ATYPE><xsl:value-of select="'R'"/></ATYPE> <VERT_LIMIT></VERT_LIMIT> <xsl:copy-of select="TEXT"/> </OBJECT> </LEVEL> </xsl:when> <xsl:when test="not(VERT_LIMIT) and COORDINATES/END_COLUMN &lt; COORDINATES/START_COLUMN and COORDINATES/END_ROW = COORDINATES/START_ROW"> <LEVEL SROW="{$srowid}"> <OBJECT ID="{@ID}"> <xsl:copy-of select="SHAPE_TYPE"/> <START_ROW><xsl:value-of select="number($srowid)"/></START_ROW> <START_COLUMN><xsl:value-of select="COORDINATES/END_COLUMN"/></START_COLUMN> <END_ROW><xsl:value-of select="number($erowid)"/></END_ROW> <END_COLUMN><xsl:value-of select="COORDINATES/START_COLUMN"/></END_COLUMN> <ATYPE><xsl:value-of select="'L'"/></ATYPE> <VERT_LIMIT></VERT_LIMIT> <xsl:copy-of select="TEXT"/> </OBJECT> </LEVEL> </xsl:when> </xsl:choose> </xsl:for-each> </xsl:for-each> </xsl:variable> <xsl:variable name="arrowmerge" doc:description="Merge Arrow objects under the appropriate row (level)"> <DIAGRAM> <xsl:for-each select="$arrowlevels/DIAGRAM/LEVEL"> <xsl:sort select="@SROW" data-type="number"/> <xsl:sort select="/START_COLUMN" data-type="number"/> <xsl:variable name="srowid"><xsl:value-of select="@SROW"/></xsl:variable> <LEVEL SROW="{$srowid}"> <xsl:for-each select="$arrows/LEVEL/OBJECT"> <xsl:if test="START_ROW=$srowid"> <xsl:copy-of select="."/> </xsl:if> </xsl:for-each> </LEVEL> </xsl:for-each> </DIAGRAM> </xsl:variable> <xsl:variable name="arrowobjs" doc:description="Create the necessary Arrow fragment objects from the Arrow in-memory tree - an object is created for each column an arrow resides in. (includes vertical and horizontal line fragments)"> <xsl:call-template name="CrtArwObj"> <xsl:with-param name="arrowsrc" select="$arrowmerge/DIAGRAM"/> <xsl:with-param name="parasrc" select="$parallels/DIAGRAM"/> <xsl:with-param name="htarray" select="$sortalllevels/DIAGRAM"/> <xsl:with-param name="dimensionsds" select="$dimensions"/> </xsl:call-template> </xsl:variable> </xsl:template> </xsl:stylesheet> ************************************************************************************************* ARROWS.xls <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:doc="urn:schemas-cagle-com:document" exclude-result-prefixes="doc"> <xsl:template name="CrtArwObj"> <xsl:param name="arrowsrc" doc:description="Arrow objects in-memory tree"/> <xsl:param name="parasrc" doc:description="Parallel objects in-memory tree"/> <xsl:param name="htarray" doc:description="Level Height in-memory tree"/> <xsl:param name="dimensionsds" doc:description="Default width and height data structure"/> <xsl:for-each select="$arrowsrc/DIAGRAM/LEVEL"> <xsl:variable name="hsrow" select="SROW"/> <xsl:for-each select="OBJECT"> <xsl:variable name="herow"><xsl:value-of select="EROW"/></xsl:variable> <xsl:choose> <xsl:when test="ATYPE = 'D'"> <xsl:variable name="totdiff" select="$herow - $hsrow"/> <xsl:variable name="curht"> <xsl:if test="$htarray/LEVEL[@SROW=$hsrow]"> <xsl:value-of select="$htarray/LEVEL[@SROW=$hsrow]/HEIGHT"/> </xsl:if> </xsl:variable> <xsl:variable name="cursrow"> <xsl:if test="$totdiff != $curht"> <xsl:for-each select="$htarray/LEVEL"> <xsl:if test="@SROW &gt; $hsrow and END_ROW = $herow"> <xsl:value-of select="$herow - HEIGHT"/> </xsl:if> </xsl:for-each> </xsl:if> </xsl:variable> <xsl:call-template name="WrtArwObj"> <xsl:with-param name="psrow" select="$cursrow"/> <xsl:with-param name="pscol" select="START_COLUMN"/> <xsl:with-param name="pecol" select="START_COLUMN"/> <xsl:with-param name="perow" select="$herow"/> <xsl:with-param name="psub" select="'AD'"/> <xsl:with-param name="ptext" select="TEXT"/> <xsl:with-param name="ptype" select="BUSINESS_OBJECT_TYPE"/> <xsl:with-param name="patype" select="ATYPE"/> <xsl:with-param name="pparasrc" select="$parasrc"/> <xsl:with-param name="phtarray" select="$htarray"/> <xsl:with-param name="pdiff" select="0"/> <xsl:with-param name="pdimensionsds" select="$dimensionsds"/> </xsl:call-template> <xsl:variable name="diff" select="$cursrow - $hsrow"/> <xsl:if test="$diff &gt; 0"> <xsl:variable name="nxtsrow"> <xsl:for-each select="$htarray/LEVEL"> <xsl:if test="@SROW &gt; $hsrow and END_ROW = $cursrow"> <xsl:value-of select="$herow - HEIGHT"/> </xsl:if> </xsl:for-each> </xsl:variable> <xsl:call-template name="WrtArwObj"> <xsl:with-param name="psrow" select="$nxtsrow"/> <xsl:with-param name="pscol" select="START_COLUMN"/> <xsl:with-param name="pecol" select="START_COLUMN"/> <xsl:with-param name="perow" select="$cursrow"/> <xsl:with-param name="psub" select="'LV'"/> <xsl:with-param name="ptext" select="''"/> <xsl:with-param name="ptype" select="''"/> <xsl:with-param name="patype" select="ATYPE"/> <xsl:with-param name="pparasrc" select="$parasrc"/> <xsl:with-param name="phtarray" select="$htarray"/> <xsl:with-param name="pdiff" select="$diff"/> <xsl:with-param name="pdimensionsds" select="$dimensionsds"/> </xsl:call-template> </xsl:if> </xsl:when> </xsl:choose> </xsl:for-each> </xsl:for-each> </xsl:template> </xsl:stylesheet> ************************************************************************************************ Example ARROWMERGE data: <ARROWMERGE> <DIAGRAM> <LEVEL SROW="1"><OBJECT ID="155"> <START_ROW>1</START_ROW> <START_COLUMN>3.25</START_COLUMN> <END_ROW>1.25</END_ROW> <END_COLUMN>3.25</END_COLUMN> <ATYPE>D</ATYPE> <VERT_LIMIT></VERT_LIMIT></OBJECT></LEVEL> <LEVEL SROW="2.5"><OBJECT ID="159"> <START_ROW>2.5</START_ROW> <START_COLUMN>2.5</START_COLUMN> <END_ROW>3</END_ROW> <END_COLUMN>2.5</END_COLUMN> <ATYPE>D</ATYPE> <VERT_LIMIT></VERT_LIMIT></OBJECT><OBJECT ID="160"> <START_ROW>2.5</START_ROW> <START_COLUMN>4</START_COLUMN> <END_ROW>3</END_ROW> <END_COLUMN>4</END_COLUMN> <ATYPE>D</ATYPE> <VERT_LIMIT></VERT_LIMIT></OBJECT></LEVEL> </DIAGRAM> </ARROWMERGE>


Please register to reply