You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by bu...@apache.org on 2002/11/13 18:39:48 UTC

DO NOT REPLY [Bug 14517] New: - Repetitive node validation

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14517>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14517

Repetitive node validation

           Summary: Repetitive node validation
           Product: Xerces-C++
           Version: 1.4
          Platform: All
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Blocker
          Priority: Other
         Component: Samples/Tests
        AssignedTo: xerces-c-dev@xml.apache.org
        ReportedBy: nicolas.gazelle@experian-scorex.com


The xsl transformation engine produce the following output instead of the one 
after, using the following input xml and xsl:

INPUT XML:

<?xml version="1.0"?>
<InputData>
	<Applicant>
		<name>NAME</name>
	</Applicant>
	<creditlist>
		<credit>
			<date>DATE1</date>
			<montant>MONTANT1</montant>
		</credit>
		<credit>
			<date>DATE2</date>
			<montant>MONTANT2</montant>
		</credit>
	</creditlist>
</InputData>


INPUT XSL:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="@*|node()">
  <xsl:copy>
  <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
 </xsl:template>

 <xsl:template match="//Applicant/name">
  <xsl:copy>
  <xsl:attribute name="TrsCritId">
  <xsl:value-of select="1"/>
  </xsl:attribute>
  <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
 </xsl:template>
 
 <xsl:template match="//creditlist/credit">
	<xsl:variable name="credit_pos" select="position()"/>
	<xsl:copy>
		
		<xsl:for-each select="date">
			<xsl:copy>
				<xsl:if test="$credit_pos = 1">
					<xsl:attribute name="TrsCritId">
  					<xsl:value-of select="2"/>
  					</xsl:attribute>
				</xsl:if>
			
				<xsl:if test="$credit_pos = 2">
					<xsl:attribute name="TrsCritId">
  					<xsl:value-of select="4"/>
  					</xsl:attribute>
				</xsl:if>
				
  				<xsl:apply-templates select="@*|node()"/>
  			</xsl:copy>
		</xsl:for-each>
		
		<xsl:for-each select="montant">
			<xsl:copy>
				<xsl:if test="$credit_pos = 1">
					<xsl:attribute name="TrsCritId">
  					<xsl:value-of select="3"/>
  					</xsl:attribute>
				</xsl:if>
			
				<xsl:if test="$credit_pos = 2">
					<xsl:attribute name="TrsCritId">
  					<xsl:value-of select="5"/>
  					</xsl:attribute>
				</xsl:if>
  				<xsl:apply-templates select="@*|node()"/>
  			</xsl:copy>
		</xsl:for-each>
	</xsl:copy>
 </xsl:template>
 
</xsl:stylesheet>

GENERATED OUTPUT:

<?xml version="1.0" encoding="UTF-8"?>
<InputData>
	<Applicant>
		<name TrsCritId="1">NAME</name>
	</Applicant>
	
	<creditlist>
		<credit><date TrsCritId="4">DATE1</date><montant 
TrsCritId="5">MONTANT1</montant></credit>
		
		<credit><date>DATE2</date><montant>MONTANT2</montant></credit>
	</creditlist>
</InputData>

CORRECT OUTPUT:

<?xml version="1.0" encoding="UTF-8"?>
<InputData>
<Applicant>
 <name TrsCritId="1">NAME</name>
</Applicant>
<creditlist>
 <credit><date TrsCritId="2">DATE1</date><montant 
TrsCritId="3">MONTANT1</montant></credit>
 <credit><date TrsCritId="4">DATE2</date><montant 
TrsCritId="5">MONTANT2</montant></credit>
</creditlist>
</InputData>

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org