Avatar of tech_question
tech_question asked on

how can I put two conditions in template match ?

my xml is like this :

<f1_author1>test</f1_author1>
<f2_author1>test1</f2_author1>
<f3_author1>test2</f3_author1>

<f1_author_id>123</f1_author_id>
<f2_author_id></f2_author_id>
<f3_author_id>4545</f3_author_id>

any record that has empty "_author1" eg: f1_author1, f2_author1, f3_author1 tags and has an "author_id" value I need to add "click here value" to all the "_author1" fields.

what is the xsl to do this ? I have the below xsl to do this. I could not add a "and" condition to the the xsl. how can
I do this ?

<xsl:template match="*[contains(name(), '_author1')]" >
		<xsl:element name="{name()}">
			<xsl:choose>
				<xsl:when test="string-length(text()) = 0">
					<xsl:text>click here</xsl:text>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text>{text()}</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:element>
	</xsl:template>

Open in new window

Web Languages and Standards

Avatar of undefined
Last Comment
Gertone (Geert Bormans)

8/22/2022 - Mon
Gertone (Geert Bormans)

this question is a little bit vague,
can you post some different examples and theexpected results?
thanks
ASKER
tech_question

Eg: if we have different customers and each of the customer could be working
in different cities or in one city or in no city. If the customer has an id and is not working in any city, (the first tax would be blank) I need all these records in my output so I need an xsl for that.

Then my xml would look like this: The xml could also have empty records. so when I run the xsl I need the output
as



input xml :

<c1_id>123</c1_id>
<c1_tax1>philly</c1_tax1>
<c1_tax2><c1_tax2>
<c1_tax3></c1_tax3>

<c2_id>4567</c2_id>
<c2_tax1></c2_tax1>
<c2_tax2></c2_tax2>
<c2_tax3></c2_tax3>

<c3_id></c3_id>
<c3_tax1></c3_tax1>
<c3_tax2></c3_tax2>
<c3_tax3></c3_tax3>

ouput xml:

<c1_id>123</c1_id>
<c1_tax1>philly</c1_tax1>
<c1_tax2><c1_tax2>
<c1_tax3></c1_tax3>

<c2_id>4567</c2_id>
<c2_tax1>click here</c2_tax1>
<c2_tax2></c2_tax2>
<c2_tax3></c2_tax3>

<c3_id></c3_id>
<c3_tax1></c3_tax1>
<c3_tax2></c3_tax2>
<c3_tax3></c3_tax3>


ASKER CERTIFIED SOLUTION
Gertone (Geert Bormans)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Your help has saved me hundreds of hours of internet surfing.
fblack61