Tizag Webmaster Forums  

Go Back   Tizag Webmaster Forums > Web Development > Markup Languages and Styling > XSLT Forum

Reply
 
Thread Tools Display Modes
  #1  
Old 11-06-2009, 04:19 PM
kb19 kb19 is offline
Curious Visitor
 
Join Date: Nov 2009
Posts: 1
kb19 will become famous soon enough
XSLT & for-each

I have an xml file that is 500 lines. I can do other XSLT operations on it fine, but when I try to do a for-each for an element that appears twice, I get no result. Is there a problem with for-each and large ( ? ) files or does the fault lie in the xml file. I know it's a tough q to ask without including the XML file but it's too long to attach / contains confidential info.

Here is the code I'm using:

Code:
<xsl:for-each select="/resources/ADT_A03/OBX">
	<xsl:variable name="OBX" select="OBX.3-Observation_Identifier/CE.1-identifier"/>
	<xsl:choose>			
	<xsl:when test="matches($OBX, 'AMB_ARRVL_DT') ">
		<xsl:element name="F_ambarrivedate"> 
		     <xsl:value-of select="OBX.5-Observation_Value/TS.1"/>
		</xsl:element>
	</xsl:when>
	<xsl:when test="matches($OBX, 'AMBTRNCAREDT') ">
		<xsl:element name="F_ambxcaredate">
		     <xsl:value-of select="OBX.5-Observation_Value/TS.1"/>
		</xsl:element>
	</xsl:when>
	</xsl:choose>
</xsl:for-each>

Last edited by kb19; 11-06-2009 at 04:25 PM.
Reply With Quote
Sponsored Links
  #2  
Old 11-07-2009, 02:01 AM
rummy rummy is offline
Curious Visitor
 
Join Date: Nov 2009
Posts: 3
rummy will become famous soon enough
Thumbs up

If only the input xml is shown, we could give a solution. You need not show the whole xml, you can give just a snippet related to the code, with some dummy data. Try giving it.
Reply With Quote
  #3  
Old 11-07-2009, 06:06 AM
Martin Honnen Martin Honnen is offline
Newbie
 
Join Date: Aug 2009
Location: Germany
Posts: 59
Martin Honnen will become famous soon enough
I don't think 500 lines is large and even if you process large documents then you are more likely to run out of memory than to encounter problems with wrong results.
Of course an XSLT processor is some software that like all software can have bugs; if you want to rule out a bug as the cause of the problem then consider to try a second XSLT processor. You seem to use XSLT 2.0 so the choice of XSLT processors is not that large but with Saxon 9, AltovaXML tools and Gestalt there is some choice.
If your XML has confidential data you can't show then, if you need help fixing the problem with your XSLT, you need to edit the XML and replace any confidential data with some dummy data. It shouldn't be too difficult to construct a small sample showing us in what way "an element ... appears twice" leads to problems.
__________________
Martin Honnen
Microsoft MVP - XML
My Blog
Reply With Quote
  #4  
Old 11-09-2009, 04:58 PM
sdutry sdutry is offline
Curious Visitor
 
Join Date: Oct 2009
Posts: 6
sdutry will become famous soon enough
Some xslt-processors won't allow you to redeclare the same variable.

so instead of declaring <xsl:variable name="OBX" select="OBX.3-Observation_Identifier/CE.1-identifier"/>

just use OBX.3-Observation_Identifier/CE.1-identifier where you use $OBX and see if that works.

If it doesn't, we realy need more information about the input.

Code:
<xsl:for-each select="/resources/ADT_A03/OBX">
    <xsl:choose>			
        <xsl:when test="matches(OBX.3-Observation_Identifier/CE.1-identifier, 'AMB_ARRVL_DT') ">
            <F_ambarrivedate><xsl:value-of select="OBX.5-Observation_Value/TS.1"/></F_ambarrivedate>
        </xsl:when>
        <xsl:when test="matches(OBX.3-Observation_Identifier/CE.1-identifier, 'AMBTRNCAREDT') ">
            <F_ambxcaredate><xsl:value-of select="OBX.5-Observation_Value/TS.1"/></F_ambxcaredate>
        </xsl:when>
    </xsl:choose>
</xsl:for-each>


Stefaan
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 11:52 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008, Tizag