Subject: [xsl] sub element selection From: Pete.Gomez@xxxxxxxxxxxxx Date: Tue, 16 Apr 2002 12:39:02 -0400 |
Hi. I'm new to XSL and have what I think is a basic question. I'm trying to do the conversion below with the stylesheet at the bottom of the email. I want to use the makeProperty template in my solution since many of the easier XSL things I've coded call it. I'm having trouble figuring out how to get the value of CommunicationType and then compare it to a string (or should it be a variable?). If you see an obviously easier way to do it (xsl:when? xsl:for-each?) please let me know. BTW - I have been checking through the various tutorials and archives listed. I think part of the problem with being new is I don't know exactly what search terms to use to get what I want. Thanks Pete ------------- XML input snippet ---------------- <CustomerContact> <ContactType>Person</ContactType> <PersonContact> <Communication> <CommunicationType>DAYPHONE</CommunicationType> <CommunicationNumber>800-5551212</CommunicationNumber> </Communication> <Communication> <CommunicationType>EMAIL</CommunicationType> <CommunicationNumber>mickey@xxxxxxxxxx</CommunicationNumber> </Communication> </PersonContact> </CustomerContact> ------------- desired XML output ---------------- (note: DAYPHONE, above, maps to HOMEPHONE and EMAIL maps to DRV1_EMAIL) <property name="HOMEPHONE" value="800-5551212"/> <property name="DRV1_EMAIL" value="mickey@xxxxxxxxxx"/> ------------- stylesheet snippet ---------------- <xsl:template match="Communication"> <xsl:apply-templates select="CommunicationType"/> </xsl:template> <xsl:template match="CommunicationType"> <xsl:if test="....?..... = 'DAYPHONE'"> <xsl:call-template name="makeProperty"> <xsl:with-param name="name">HOMEPHONE</xsl:with-param> <xsl:with-param name="value" select="....?......" /> <!-- i want to get CommunicationNumber here --> </xsl:call-template> </xsl:if> <xsl:if test="....?..... = 'EMAIL'"> <xsl:call-template name="makeProperty"> <xsl:with-param name="name">DRV1_EMAIL</xsl:with-param> <xsl:with-param name="value" select="....?...." /> <!-- i want to get CommunicationNumber here --> </xsl:call-template> </xsl:if> </xsl:template> <xsl:template name="makeProperty"> <xsl:param name="name"/> <xsl:param name="value"/> <property> <xsl:attribute name="name"> <xsl:value-of select="$name" /> </xsl:attribute> <xsl:attribute name="value"> <xsl:value-of select="$value" /> </xsl:attribute> </property> </xsl:template> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] XSLT conformance membership, Carmelo | Thread | Re: [xsl] sub element selection, Jeni Tennison |
Re: [xsl] creating and accessing el, Charly | Date | RE: [xsl] further question regardin, 林 子芯 |
Month |