cancel
Showing results for 
Search instead for 
Did you mean: 

xsl for:each returns first occurrance only

Former Member
0 Kudos

Hi all:

Using <SERVLET> with XSL to get HTML. The for:each is only returning the first child.

I saw a bug report from XALAN 2.4.1. What stylesheet engine and version are we using in MII 12.0

BTW -- XMLSPY doesn't have any problem with this, it selects all hdr children and all col children.

Thanks,

--Amy Smith

--Haworth


<?xml version="1.0" encoding="UTF-8"?>
<Rowsets DateCreated="2009-08-21T16:17:01" EndDate="2009-08-07T16:03:42" StartDate="2009-08-07T16:03:42" Version="12.0.4 Build(120)">
	<Rowset>
		<Columns>
			<Column Description="" MaxRange="1" MinRange="0" Name="hdr" SQLDataType="1" SourceColumn="hdr"/>
			<Column Description="" MaxRange="1" MinRange="0" Name="col" SQLDataType="1" SourceColumn="col"/>
		</Columns>
		<Row>
			<hdr>Prod Ord</hdr>
			<hdr>Name</hdr>
		</Row>
		<Row>
			<col>1000034</col>
			<col>Amy Smith</col>
		</Row>
		<Row>
			<col>1000041</col>
			<col>Amy Smith</col>
		</Row>
		<Row>
			<col>1000042</col>
			<col>Amy Smith</col>
		</Row>
	</Rowset>
</Rowsets>

Can't post the html here, so use you imagination that there is html being generated with select="." inside the

for each hdr and for each col.



<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="/">
	<xsl:apply-templates select="/Rowsets/Rowset[1]" />
</xsl:template>
<xsl:template match="/Rowsets/Rowset[1]">
<xsl:for-each select="Row[1]">
	<xsl:for-each select="hdr">
	</xsl:for-each>
</xsl:for-each>
<xsl:for-each select="Row">
	<xsl:for-each select="col">
	</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hmmm...

I had to make each column a unique name and add the meta data to the Columns tag before it would process properly.

Processing fine now.

This seems to be a special requirement. or restriction. Am I right then that there are non-standard rules for processing xsl?

If so, how do I find out what they are?

Thanks,

--Amy Smith

--Haworth

jcgood25
Active Contributor
0 Kudos

Your Illum Doc is not valid - maybe it was a typo, but each Row must have the same Data Items as declared in the Columns secion. Obviously if you are just emulating this in an xml format that's one thing, but it may cause you issues downstream if you are trying to use an XacuteQuery and the Stylesheet approach in a SERVLET.

Former Member
0 Kudos

Thanks Jeremy,

I get it now. The xml has to be a valid Illum Doc in addition to being valid xml.

Is that true for anything that is processed by the stylesheet engine in MII?

--Thanks Jeremy,

--Amy

jcgood25
Active Contributor
0 Kudos

If you are using SERVLET calls with queries then it's better to be safe than sorry. I don't know what you may encounter, but the XacuteQuery template may try to rectify some of the unkosher xml construct and it may add more confusion to your xsl development, especially if you are using a static xml document and transforming it in a 3rd party tool.

So, better to toe the line and worry only about the nuances of xslt than to add another wrinkle into it with malformed Rowset documents...

Former Member
0 Kudos

Thanks Jeremy,

That is great advice that I will follow.

Just for clarification for anyone reading this, the document I was trying to use was not malformed XML, but it was a malformed Illum Document. The xsl I was using worked in a couple of different engines, including XMLSPY. It did NOT work in the MII Engine because the document was not in Illum Document format.

Thanks again and everything is working great. Thanks for all your help. And thanks to everyone else who helped!

--Amy Smith

--Haworth

jcgood25
Active Contributor
0 Kudos

I can't help but be curious - what happens if you rendered the malformed Illum Doc with the defacto standard xsl (IllumRowsetHTML.xsl) or just tested your query template and selected text/xml output? I wonder if the environment was a bit different in the standalone tool, as opposed to any query or xml cleanup that might have been done by the query engine.

Former Member
0 Kudos

That would be an interesting test. However everything has been changed to work properly and (have you heard this before?) I haven't got time to see where it is going sideways. If you test it, let us all know the results!

Thanks Jeremy,

--Amy

jcgood25
Active Contributor
0 Kudos

In a quick XMLQuery test where I created an xml file from your earlier post the document does get reconstituted based upon your column definition of:

<Column Description="" MaxRange="1" MinRange="0" Name="hdr" SQLDataType="1" SourceColumn="hdr" />

<Column Description="" MaxRange="1" MinRange="0" Name="col" SQLDataType="1" SourceColumn="col" />

- <Row>

<hdr>Prod Ord</hdr>

<col>---</col>

</Row>

- <Row>

<hdr>---</hdr>

<col>1000034</col>

</Row>

- <Row>

<hdr>---</hdr>

<col>1000041</col>

</Row>

- <Row>

<hdr>---</hdr>

<col>1000042</col>

</Row>

This might explain why it only did the first iteration, because hdr only exists once in Row[1], not twice like in your atypical Rowset xml