homepage Welcome to WebmasterWorld Guest from 54.166.111.111
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / XML Development
Forum Library, Charter, Moderators: httpwebwitch

XML Development Forum

    
XSLT and Nested Evaluation Statements
jmorgan1422




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

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]

 

httpwebwitch




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

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?

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / XML Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved