Subject: RE: [xsl] Unwanted New Line on Output From: cknell@xxxxxxxxxx Date: Mon, 18 Jun 2007 06:20:51 -0400 |
Q. Is this caused because the dept_id is at a higher level in the XML structure? A. No. Q. Is this a problem with my select="DEPT" actually selecting something more than just the ID for the department. A. No. It's caused by the carriage return and linefeed that you have put in your XML file, i.e.: <DEPT> 1 <EMPS> I suggest that you re-structure your XML and template to look like this: <DEPT> <DEPT_NUM>1</DEPT_NUM> <EMPS> <EMP_NAME> Fred Bloggs</EMP_NAME> <EMP_AGE> 25 </EMP_AGE> </EMPS> <EMPS> <EMP_NAME> Joe Smith</EMP_NAME> <EMP_AGE> 35 </EMP_AGE> </EMPS> </DEPT> <xsl:template mode="depts" match="DEPT"> <xsl:value-of select="DEPT_NUM" /> <xsl:value-of select="EMP_NAME" /> </xsl:template> There is absolutely no need for <xsl:for-each> and <xsl:param> in this situation. It only confuses things. -- Charles Knell cknell@xxxxxxxxxx - email -----Original Message----- From: Matt <puskas.duck@xxxxxxxxx> Sent: Mon, 18 Jun 2007 10:49:17 +0100 To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: [xsl] Unwanted New Line on Output Morning list! I have the following XML structure: <DEPT_DETAILS> <DEPT> 1 <EMPS> <EMP_NAME> Fred Bloggs</EMP_NAME> <EMP_AGE> 25 </EMP_AGE> </EMPS> <EMPS> <EMP_NAME> Joe Smith</EMP_NAME> <EMP_AGE> 35 </EMP_AGE> </EMPS> </DEPT> <DEPT> 2 <EMPS> <EMP_NAME> Jill Bloggs</EMP_NAME> <EMP_AGE> 19 </EMP_AGE> </EMPS> <EMPS> <EMP_NAME> Gerry Halliwell</EMP_NAME> <EMP_AGE> 45 </EMP_AGE> </EMPS> </DEPT> </DEPT_DETAILS> I want the following output (as text): 1 Fred Bloggs 1 Joe Smith 2 Jill Bloggs 2 Gerry Halliwell So my template looks something like: <xsl:apply-template mode="depts" select="DEPT_DETAILS/DEPT"/> <xsl:template mode="depts" match="*"> <xsl:param name="deptID" select="DEPT"/> <xsl:for-each select="EMPS"> <xsl:value-of select="$deptID"/> <xsl:value-of select="EMP_NAME"/> <xsl:text> </xsl:text> <!-- Add CR --> </xsl:for-each> </xsl:template> But the output I am getting is along the lines of: 1 Fred Bloggs 1 Joe Smith 2 Jill Bloggs 2 Gerry Halliwell With the emp name being on a second line. Is this caused because the dept_id is at a higher level in the XML structure? Is this a problem with my select="DEPT" actually selecting something more than just the ID for the department. Any answers/suggestions appreciated.... Matt
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Unwanted New Line on Outp, Manfred Staudinger | Thread | [xsl] test -- please ignore this em, sudheshna iyer |
Re: [xsl] Unwanted New Line on Outp, Manfred Staudinger | Date | [xsl] test -- please ignore this em, sudheshna iyer |
Month |