Subjects
Home
Xalan extension functions
Fomatting question serializing DOM with pretty print
xalan with pull parser
Cannot find the declaration
Apache Xalan drop support to run on JRE 1 1 x
Why does Doctype change processing of a document
Node set to XML string via Java extensions in Xalan J: possible?
Templates/Transformers + thread safety???
Problem evaluating xpath with muliple prefix with different namespace
remove an arbitrary attribute from xsl output
Xalan3 XSLT 2 0 XPath 2 0 support?
Problem using compiled translets with Xalan !!
Xalan and jstl 1 1 problem with transform tag
NullPointer in DOM2DTM getLocalName
URIResolvers base parameter with xsltc and cascaded imports
Performance problem for Xalan J on intel dual core
Standard libraries in JAXP?
Serializing a DOM tree to XML file, customize entities replacement
Library Conflict Involving BCEL Library
A question on how users are using <xsl:message >
Kevin Cormier as a new Apache Xalan J committer
Struggling to iterate over tokenized string
Xalan count() trouble
Problem with recursive xpath
Error when switching to java 1 5
document( ' ')
Problem with Xalan2 7 0 transformation
cr/lf options
entity encoded XML
can xalan transform 2 xml using one xslt?
Xalan J JIRA defect review Monday October 16, 2006 from 2:00 to 3:30 pm ED
xsl transform with cdata section elements
xslt parameters not expanded
Weird behavior of XPath evaluate()
How to avoid <xsl:message > instruction prints stylesheet file informations ?
Cannot find SimpleTransform subdirectory after installing Xalan J
recover from document not found exceptions
jdk1 5 and Xalan jar differences?
Performance Issue
Error/Bug adding floating point numbers
XPathAPI: eval exp using nodes with default namespace
modifying xalan to output invalid XML
NullPointerException
mege two separate xml nodes into one
Is this a XALAN document identification bug?
is StylesheetRoot really java io Serializable ?
transform() fails for DOMSource but succeeds for StreamSource
Thoughts on Transformer parameter passing
HELP, Xalan and jstl 1 1 problem with transformer
Problem with XPath namespace axis?
string utils:replace deleting search string if replacement string is an HTML
help with enumeration values pls
xalan 2 5 1 vs 2 7 performance question
How to insert/update in XML document
HTML Serialization and Handling of Ampersands in HREF Attributes
XHTML link tag stripping
SystemId Unknown; Line #24; Column #49; java lang NullPointerException
xpath text() help
Apostrophe problem with xalan 2 7 0
How to set variables in XML document?
Links
Home
Oracle database error code ...
 
Search:  
Power your search with and, or, +, -, or "some phrase" operators.
XSL for-each problem

XSL for-each problem

2005-11-09       - By Christine Li
Reply:     1     2     3     4     5  

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>&quot;Kalcevich, Daniel&quot;
&lt;dkalcevich@(protected)&gt;</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">&nbsp;</font>
<br><font size=2 face="Arial">I am trying to transform a stylesheet and
I am running into a problem with the &lt;xsl:for-each&gt; element. &nbsp;I
want to select all &lt;violation&gt; elements underneath the &lt;violations&gt;
element. &nbsp;There are 3 shown in the XML below. &nbsp;Anyways, I am
trying to use the XPath query &#8220;//listing/violations/violation&#8221; but
when
I do, it loops through my code 12 times! &nbsp;I am trying to find the
right XPath query so that it only searches 3 times. &nbsp;Any help is
appreciated.
&nbsp;Any help is appreciated! &nbsp;Thanks.</font>
<br><font size=2 face="Arial">&nbsp;</font>
<br><font size=2 face="Arial">&nbsp;</font>
<br><font size=2 face="Arial">//////////////////////////// XML File ///////////
///////////////////</font>
<br><font size=2 face="Arial">&nbsp;</font>
<br><font size=2 face="Courier New">&lt;?xml version=&quot;1.0&quot; encoding=
&quot;UTF-8&quot;?&gt;</font>
<br><font size=2 face="Courier New">&lt;xml&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &lt;listing&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &lt;violations
&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &lt;violation&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &lt;violation_num&gt;2.4&lt;/violation_num&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &lt;violation_type_desc&gt;Misuse of Public Remarks&lt;
/violation_type_desc&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &lt;violation_mlsrule_no&gt;MLs rule for id 2&lt;
/violation_mlsrule_no&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &lt;violation_desc&gt;some description for Violation
ID : 2&lt;/violation_desc&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &lt;examples&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;violation_example&gt;Example 1&lt;
/violation_example&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;violation_example&gt;Example 2&lt;
/violation_example&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &lt;/examples&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &lt;/violation&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &lt;violation&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &lt;violation_num&gt;1.3&lt;/violation_num&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &lt;violation_type_desc&gt;Misuse of Agent Remarks&lt;
/violation_type_desc&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &lt;violation_mlsrule_no&gt;MLS rule ID 3&lt;/violation
_mlsrule_no&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &lt;violation_desc&gt;something with violation id
3 &lt;/violation_desc&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &lt;examples&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;violation_example&gt;Example 3&lt;
/violation_example&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;violation_example&gt;Example4&lt;
/violation_example&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &lt;/examples&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &lt;/violation&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &lt;violation&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &lt;violation_num&gt;1.3&lt;/violation_num&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &lt;violation_type_desc&gt;Misuse of Agent Remarks&lt;
/violation_type_desc&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &lt;violation_mlsrule_no&gt;MLS rule ID 3&lt;/violation
_mlsrule_no&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &lt;violation_desc&gt;something with violation id
3 &lt;/violation_desc&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &lt;examples&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;violation_example&gt;Example 5&lt;
/violation_example&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &lt;/examples&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &lt;/violation&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &lt;/violations
&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &lt;/listing&gt;</font>
<br><font size=2 face="Courier New">&lt;/xml&gt;</font>
<br><font size=2 face="Courier New">&nbsp;</font>
<br><font size=2 face="Courier New">&nbsp;</font>
<br><font size=2 face="Courier New">//////////////////// XSL</font>
<br><font size=2 face="Courier New">&nbsp;</font>
<br><font size=2 face="Courier New">&lt;xsl:for-each select=&#8221;//listing
/violations/violation&#8221;&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &lt;xsl:value-of
selec=&#8221;violation_num&#8221;/&gt;</font>
<br><font size=2 face="Courier New">&lt;/xsl:for-each&gt;</font>
<br><font size=2 face="Arial">&nbsp;</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">&nbsp;</font>
<br>