  | |  | XSL for-each problem | XSL for-each problem 2005-11-09 - By Christine Li
Hi, Daniel
I can't tell why you got wrong result without seeing your stylesheet. Post your stylesheet, I may help.
Christine Li XSLT Development IBM Toronto Lab Tel: (905)413-2601 Email: jycli@(protected)
"Kalcevich, Daniel" <dkalcevich@(protected)> 09/11/2005 01:12 PM
To xalan-j-users@(protected) cc
Subject XSL for-each problem
Everyone, I am trying to transform a stylesheet and I am running into a problem with the <xsl:for-each> element. I want to select all <violation> elements underneath the <violations> element. There are 3 shown in the XML below. Anyways, I am trying to use the XPath query ?//listing/violations/violation? but when I do, it loops through my code 12 times! I am trying to find the right XPath query so that it only searches 3 times. Any help is appreciated. Any help is appreciated! Thanks. //////////////////////////// XML File ////////////////////////////// <?xml version="1.0" encoding="UTF-8"?> <xml> <listing> <violations> <violation> <violation_num>2.4</violation_num> <violation_type_desc>Misuse of Public Remarks</violation_type_desc> <violation_mlsrule_no>MLs rule for id 2</violation_mlsrule_no> <violation_desc>some description for Violation ID : 2</violation_desc> <examples> <violation_example>Example 1</violation_example> <violation_example>Example 2</violation_example> </examples> </violation> <violation> <violation_num>1.3</violation_num> <violation_type_desc>Misuse of Agent Remarks</violation_type_desc> <violation_mlsrule_no>MLS rule ID 3</violation_mlsrule_no> <violation_desc>something with violation id 3 </violation_desc> <examples> <violation_example>Example 3</violation_example> <violation_example>Example4</violation_example> </examples> </violation> <violation> <violation_num>1.3</violation_num> <violation_type_desc>Misuse of Agent Remarks</violation_type_desc> <violation_mlsrule_no>MLS rule ID 3</violation_mlsrule_no> <violation_desc>something with violation id 3 </violation_desc> <examples> <violation_example>Example 5</violation_example> </examples> </violation> </violations> </listing> </xml> //////////////////// XSL <xsl:for-each select=?//listing/violations/violation?> <xsl:value-of selec=?violation_num?/> </xsl:for-each> Daniel Kalcevich Software Engineer SCJP,SCWCD ext. 7503
<br><font size=2 face="sans-serif">Hi, Daniel</font> <br> <br><font size=2 face="sans-serif">I can't tell why you got wrong result without seeing your stylesheet. Post your stylesheet, I may help.</font> <br> <br><font size=2 face="sans-serif">Christine Li<br> XSLT Development<br> IBM Toronto Lab<br> Tel: (905)413-2601<br> Email: jycli@(protected)</font> <br> <br> <br> <table width=100%> <tr valign=top> <td width=40%><font size=1 face="sans-serif"><b>"Kalcevich, Daniel" <dkalcevich@(protected)></b> </font> <p><font size=1 face="sans-serif">09/11/2005 01:12 PM</font> <td width=59%> <table width=100%> <tr> <td> <div align=right><font size=1 face="sans-serif">To</font></div> <td valign=top><font size=1 face="sans-serif">xalan-j-users@(protected)< /font> <tr> <td> <div align=right><font size=1 face="sans-serif">cc</font></div> <td valign=top> <tr> <td> <div align=right><font size=1 face="sans-serif">Subject</font></div> <td valign=top><font size=1 face="sans-serif">XSL for-each problem</font>< /table> <br> <table> <tr valign=top> <td> <td></table> <br></table> <br> <br> <br><font size=2 face="Arial">Everyone,</font> <br><font size=2 face="Arial"> </font> <br><font size=2 face="Arial">I am trying to transform a stylesheet and I am running into a problem with the <xsl:for-each> element. I want to select all <violation> elements underneath the <violations> element. There are 3 shown in the XML below. Anyways, I am trying to use the XPath query “//listing/violations/violation” but when I do, it loops through my code 12 times! I am trying to find the right XPath query so that it only searches 3 times. Any help is appreciated. Any help is appreciated! Thanks.</font> <br><font size=2 face="Arial"> </font> <br><font size=2 face="Arial"> </font> <br><font size=2 face="Arial">//////////////////////////// XML File /////////// ///////////////////</font> <br><font size=2 face="Arial"> </font> <br><font size=2 face="Courier New"><?xml version="1.0" encoding= "UTF-8"?></font> <br><font size=2 face="Courier New"><xml></font> <br><font size=2 face="Courier New"> <listing></font> <br><font size=2 face="Courier New"> <violations ></font> <br><font size=2 face="Courier New"> <violation></font> <br><font size=2 face="Courier New"> <violation_num>2.4</violation_num></font> <br><font size=2 face="Courier New"> <violation_type_desc>Misuse of Public Remarks< /violation_type_desc></font> <br><font size=2 face="Courier New"> <violation_mlsrule_no>MLs rule for id 2< /violation_mlsrule_no></font> <br><font size=2 face="Courier New"> <violation_desc>some description for Violation ID : 2</violation_desc></font> <br><font size=2 face="Courier New"> <examples></font> <br><font size=2 face="Courier New"> <violation_example>Example 1< /violation_example></font> <br><font size=2 face="Courier New"> <violation_example>Example 2< /violation_example></font> <br><font size=2 face="Courier New"> </examples></font> <br><font size=2 face="Courier New"> </violation></font> <br><font size=2 face="Courier New"> <violation></font> <br><font size=2 face="Courier New"> <violation_num>1.3</violation_num></font> <br><font size=2 face="Courier New"> <violation_type_desc>Misuse of Agent Remarks< /violation_type_desc></font> <br><font size=2 face="Courier New"> <violation_mlsrule_no>MLS rule ID 3</violation _mlsrule_no></font> <br><font size=2 face="Courier New"> <violation_desc>something with violation id 3 </violation_desc></font> <br><font size=2 face="Courier New"> <examples></font> <br><font size=2 face="Courier New"> <violation_example>Example 3< /violation_example></font> <br><font size=2 face="Courier New"> <violation_example>Example4< /violation_example></font> <br><font size=2 face="Courier New"> </examples></font> <br><font size=2 face="Courier New"> </violation></font> <br><font size=2 face="Courier New"> <violation></font> <br><font size=2 face="Courier New"> <violation_num>1.3</violation_num></font> <br><font size=2 face="Courier New"> <violation_type_desc>Misuse of Agent Remarks< /violation_type_desc></font> <br><font size=2 face="Courier New"> <violation_mlsrule_no>MLS rule ID 3</violation _mlsrule_no></font> <br><font size=2 face="Courier New"> <violation_desc>something with violation id 3 </violation_desc></font> <br><font size=2 face="Courier New"> <examples></font> <br><font size=2 face="Courier New"> <violation_example>Example 5< /violation_example></font> <br><font size=2 face="Courier New"> </examples></font> <br><font size=2 face="Courier New"> </violation></font> <br><font size=2 face="Courier New"> </violations ></font> <br><font size=2 face="Courier New"> </listing></font> <br><font size=2 face="Courier New"></xml></font> <br><font size=2 face="Courier New"> </font> <br><font size=2 face="Courier New"> </font> <br><font size=2 face="Courier New">//////////////////// XSL</font> <br><font size=2 face="Courier New"> </font> <br><font size=2 face="Courier New"><xsl:for-each select=”//listing /violations/violation”></font> <br><font size=2 face="Courier New"> <xsl:value-of selec=”violation_num”/></font> <br><font size=2 face="Courier New"></xsl:for-each></font> <br><font size=2 face="Arial"> </font> <br><font size=2 face="Arial"><b>Daniel Kalcevich</b></font> <br><font size=2 face="Arial">Software Engineer</font> <br><font size=2 face="Arial">SCJP,SCWCD</font> <br><font size=2 face="Arial">ext. 7503</font> <br><font size=3 face="Times New Roman"> </font> <br>
|
|
 |