Welcome to WebmasterWorld Guest from 54.146.59.202

Forum Moderators: httpwebwitch

Message Too Old, No Replies

XSLT and Nested Evaluation Statements

     
5:31 pm on Mar 2, 2010 (gmt 0)

5+ Year Member



I am wondering what the best way to filtering out a certain repeating element by referencing its attribute tag. I want to suppress the B1 attribute from being processed.

XML
<NameInfo id="B1" AffiliationRefs="I1394"
<NameInfo id="C1" AffiliationRefs="I1263">
<NameInfo id="C2" AffiliationRefs="I1263">
<NameInfo id="C3" AffiliationRefs="I1263">

Current XSLT without additional filter logic
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:bpws="http://---------------/" xmlns:acord="http://------------/xml/"
exclude-result-prefixes="xs"
version="2.0">


<!-- <xsl:variable name="NameInfoId" select="bpws:getVariableData('nameInfoId')"/>-->
<xsl:variable name="NameInfoId">
<!--<InsuredOrPrincipal>
<GeneralPartyInfo>-->
<NameInfo id="C1" xmlns="http://------------/xml/" xmlns:p0="http://-------------/xml/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<!-- </GeneralPartyInfo>
</InsuredOrPrincipal>-->
</xsl:variable>


<xsl:template match="acord:InsuredOrPrincipal">

<!-- <xsl:element name="ID">
<xsl:value-of select="$NameInfoId/NameInfo/@id"/>
</xsl:element>-->


<xsl:variable name="NameInfoId">
<xsl:value-of select="$NameInfoId/acord:NameInfo/@id"/>
</xsl:variable>

<xsl:element name="EmployerContactInfo">
<xsl:for-each select="//acord:NameInfo">

<xsl:if test="./@id = $NameInfoId">
<xsl:element name="PersonName">
<xsl:element name="SurName">
<xsl:value-of select=".//acord:Surname"/>
</xsl:element>
<xsl:element name="GivenName">
<xsl:value-of select=".//acord:GivenName"/>
</xsl:element>
<xsl:element name="OtherGivenName">
<xsl:value-of select=".//acord:OtherGivenName"/>
</xsl:element>
<xsl:element name="TitlePrefix">
<xsl:value-of select=".//acord:TitlePrefix"/>
</xsl:element>
<xsl:element name="NameSuffix">
<xsl:value-of select=".//acord:NameSuffix"/>
</xsl:element>
<xsl:element name="TitleRelationshipDesc">
<xsl:value-of select=".//acord:TitleRelationshipDesc"/>
</xsl:element>

<xsl:for-each select="//acord:PhoneInfo">
<xsl:if test="@id = $NameInfoId">
<xsl:element name="PhoneInfo">
<xsl:element name="PhoneTypeCd">
<xsl:value-of select=".//acord:PhoneTypeCd"></xsl:value-of>
</xsl:element>
<xsl:element name="PhoneNumber">
<xsl:value-of select=".//acord:PhoneNumber"></xsl:value-of>
</xsl:element>
<xsl:element name="EmailAddr">
<xsl:value-of select=".//acord:EmailAddr"></xsl:value-of>
</xsl:element>
</xsl:element>
</xsl:if>
</xsl:for-each>


</xsl:element>
</xsl:if>
</xsl:for-each>
</xsl:element>
</xsl:template>

<xsl:template match="text()"/>

</xsl:stylesheet>

[edited by: httpwebwitch at 9:51 pm (utc) on Mar 3, 2010]
[edit reason] removed URLs from namespaces [/edit]

10:00 pm on Mar 10, 2010 (gmt 0)

WebmasterWorld Administrator httpwebwitch is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Hi jmorgan1422,
welcome to WebmasterWorld!

my guess is you'll use an if or a choose, using an XPATH condition that matches nodes without that attribute... any luck on this yet?
 

Featured Threads

Hot Threads This Week

Hot Threads This Month