Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Not extracting data correctly

From: "Eric Stott" <ericstott@------.------>
To: NULL
Date: 9/8/2008 4:41:00 PM

The following input xml looks like this:
<ns0:Root xmlns:ns0="http://Schemas.Input">
  <Record>
   <SubRecord Qualifier="AA">
    <Data>Here is AA Data</Data>
   </SubRecord>
   <SubRecord Qualifier="ZZ">
    <Data>Here is ZZ Data</Data>
   </SubRecord>
  </Record>
</ns0:Root>

I have the following xsl:
<?xml version="1.0" encoding="UTF-16"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:msxsl="urn:schemas-microsoft-com:xslt" 
xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var" 
exclude-result-prefixes="msxsl var s0 userCSharp" version="1.0" 
xmlns:s0="http://Schemas.Input" xmlns:ns0="http://Schemas.Output" 
xmlns:userCSharp="http://schemas.microsoft.com/BizTalk/2003/userCSharp">

<xsl:output omit-xml-declaration="yes" method="xml" version="1.0" 
indent="yes" />

<xsl:template match="/">

<xsl:apply-templates select="/s0:Root" />

</xsl:template>

<xsl:template match="/s0:Root">

<ns0:Root>

<Record>

<xsl:for-each select="Record">

<xsl:variable name="var:v1" 
select="userCSharp:LogicalEq(string(SubRecord/@Qualifier) , &quot;ZZ&quot;)" 
/>

<xsl:if test="string($var:v1)='true'">

<xsl:variable name="var:v2" select="SubRecord/Data/text()" />

<Data>

<xsl:value-of select="$var:v2" />

</Data>

</xsl:if>

</xsl:for-each>

</Record>

</ns0:Root>

</xsl:template>

<msxsl:script language="C#" implements-prefix="userCSharp"><![CDATA[

public bool LogicalEq(string val1, string val2)

{

bool ret = false;

double d1 = 0;

double d2 = 0;

if (IsNumeric(val1, ref d1) && IsNumeric(val2, ref d2))

{

ret = d1 == d2;

}

else

{

ret = String.Compare(val1, val2, StringComparison.Ordinal) == 0;

}

return ret;

}



public bool IsNumeric(string val)

{

if (val == null)

{

return false;

}

double d = 0;

return Double.TryParse(val, System.Globalization.NumberStyles.AllowThousands 
| System.Globalization.NumberStyles.Float, 
System.Globalization.CultureInfo.InvariantCulture, out d);

}

public bool IsNumeric(string val, ref double d)

{

if (val == null)

{

return false;

}

return Double.TryParse(val, System.Globalization.NumberStyles.AllowThousands 
| System.Globalization.NumberStyles.Float, 
System.Globalization.CultureInfo.InvariantCulture, out d);

}



]]></msxsl:script>

</xsl:stylesheet>



However it does not pull the data (because it is not the first occurence), 
how can I get it to span thru all of the subrecords but still drive the 
output based on the input record.




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent