override an "xsl:value-of"

hello all,
 I'm absolutely not sure of my idea...so please have mercy if it's silly :=)
 I must configure some loan/return email-letters of a set of different libraries.
 The XML of these letters has a section (called "notification_data/general data") that sadly is common for all the libraries.
 It's like the following:
.....
<general_data>
<current_date>09/07/2015</current_date>
<address_from>libraries@foo.org</address_from>
<letter_name>Loan letter</letter_name>
.....
</general_data>
......
sadly the software house says that these data should be common to all the libraries...that's OK for <current_date>, but not for <address_from> (every library has its own address...).

I'm a XML newbie...but I've noted that a <library_name> tag is implemented by the sw house,  so I've tought to put inside the XSL of the letters a conditional like:

  <xsl:for-each select="notification_data/general_data">
      <xsl:if test="/notification_data/item_loans/item_loan/library_name='library xyz'">

      ***override <xsl:value-of select="address_from"/> returned common value  with the value suitable for the library XYZ***

      </xsl:if>
  </xsl:for-each>
 
  tha problem is that I'm absolutely not sure if this override is possible....
 
  Thanks everyway for your reply,
 
  Fabianope
fabiano petroneAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Geert BormansInformation ArchitectCommented:
Yes you can in various ways

Can you first explain what the XSLT is doing?
a. you want an XSLT simply to change the library name?
b this is an XSLT doing something and you need to integrate the library change?

Usually you would have a global parameter in your stylesheet so you can pass the new value from outside the XSLT (unless it is fixed)
Then you can replace the library address with the new value

Oh, and please use apply-templates instead of xsl:for-each to visit the nodes
0
fabiano petroneAuthor Commented:
Hi, Geert
here are the answers:
a. you want an XSLT simply to change the library name?
r: no, I want to change the default & sadly-common-to-all-libraries <email_from> address
(in the real word, every library of the campus has its own <email_from> address :=))

b this is an XSLT doing something and you need to integrate the library change?
yes, I believe :=)...the XSLT prints & formats  the loan/return letters for the books...sadly it has a mail_from address common for all libraries...I want to change it in the final loan/return mail sent to the patron...
For now, I've tested that I can pass in the XSL some formatting commands "conditionally", like:

  <xsl:for-each select="notification_data/general_data">
      <xsl:if test="/notification_data/item_loans/item_loan/library_name='library xyz'">

<!-- print in bold a welcome message -->
<B>Welcome to the library XYZ!!</B>
      </xsl:if>
  </xsl:for-each>

and it works...I don't know if I can change also default values in the same way...
Thanks in advance for the reply,


>Oh, and please use apply-templates instead of xsl:for-each to visit the nodes
sorry for this...as I've said I'm a newbie here...is it deprecated?

Thanks,
Fabianope
0
Geert BormansInformation ArchitectCommented:
you can change the value, no problem.
Where would you get the value from?

Can you send the entire stylesheet?
Adding a message based on a condition is easier, for changing the value, you need to see where the value has been output and change it there

apply templates is a different programming style. But it breaks your stylesheet up in different rules which is like 100 times easier for later maintenance and understanding

Where would you get the value from?
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

fabiano petroneAuthor Commented:
Hi, Geert
excuse me the delay in answering. I enclose the xml of the book return receipt letter (FulReturnReceiptLetter.xml) with <!-- comments -->  pointing to the email tag I'd like to personalize per library and the tag regarding the libraries name.
I enclose the relative xls too (returnreceipt.xsl) and the other six XLSs called by it
Thanks,
fabianope
footer.xsl
FulReturnReceiptLetter.xml
header.xsl
mailreason.xsl
recordtitle.xsl
returnreceipt.xsl
senderReceiver.xsl
style.xsl
0
Geert BormansInformation ArchitectCommented:
It took me a while to figure this out, but the email address is not used at all in the stylesheet

But her is what you can do... and add as many "when" clauses as you please

       	<!-- random location -->
           	<p>
        		<xsl:choose>
        			<xsl:when test="normalize-space(/notification_data/items/item_loan/library_name) = 'Scientifica Rizzi'">
        				<xsl:text>rizzi@rizzibib.com</xsl:text>
        			</xsl:when>
        			<xsl:otherwise>
        				<xsl:value-of select="notification_data/general_data/address_from"/>
        			</xsl:otherwise>
        		</xsl:choose>
        	</p>
        	

Open in new window

0
fabiano petroneAuthor Commented:
Hi,
Thanks a lot for your reply.
I've tried to put this code inside "senderReceiver.xsl" but it doesn't work...maybe I've not understood good?
Thanks,
Fabiano
0
Geert BormansInformation ArchitectCommented:
You need to put it inside the main template and make sure it is active
0
fabiano petroneAuthor Commented:
Hi,
all and only templates I can access are there I've sent you in attachment...I've tried your code with all of them but I haven't obtained the desired result...
0
Geert BormansInformation ArchitectCommented:
Well, I will return from holidays in a day or two. Will look in more detail then.
But you are a bit vague... What is the "desired result"?
I have tested you stylesheets with the source and it outputs something, as i expected.
So try to add some random text somewhere to see you control the templates
I tried it myself in the main template and it works fine. So you need to tell me what it does not
Maybe you should add some fixed text inside the xsl:otherwise or debug text in each branch
0
fabiano petroneAuthor Commented:
Hi, Geert
I confirm the content of my 2015-07-22  message.
I've tried to put your XML on each of the 8 files that I can edit (files sent to you with the 2015-07-10 post) but nothing happens...maybe I've put the code in the wrong place.
In this case can you send me one (or mole) of these files "patched" with your code, so I can see where it should be exactly pasted?
Thanks,
Fabiano
0
Geert BormansInformation ArchitectCommented:
Will do so on Monday
0
Geert BormansInformation ArchitectCommented:
I added the code directly beneath
<div class="messageBody">
but I also added some dummy markers like this, to easily spot what I added
<xsl:text>##wb1##</xsl:text>

this works very nicely with the XML source you sent.

There might be one issue
I see all sorts of markers like this
@@dear@@
the issue might be that there is a post process that uses these markers as placeholders and replace them after the fact.
That process could be ruining things. You need to be very carefull what you have at each step in the process
returnreceipt.xsl
0
fabiano petroneAuthor Commented:
Hi, Geert
sadly it does not make its job for me.
I enclose the result of the return receipt letter (excuse the italian language in the letter) after editing it using your solution.
As you see, sadly the "address from" is always the same and unmodified (biblioteche.udine@uniud.it).
Your address ( rizzi@rizzibib.com) is printed instead inside the body of the letter.
But plz don't worry...if this is the best we can do with this configuration, I'll accept surely this solution to this case :=)))

Thanks for your efforts,
Fabiano
letter.jpg
0
Geert BormansInformation ArchitectCommented:
Hi Fabiano,

I never expected the address to be at the right spot. I understood it was not appearing at all.
Thanks for the screenshot. It actually proves my code is working.
Now we just need to add it to the right location.
Is it the "bibliothech.udine@uniud.it [... ]" that you want to change?
This now for me is a simple matter of tracing that string and add my code at the right location.
I can't do that from my current working spot. but I will definitely do so this evening.
I am located near Brussels so in your timezone, I expect you to only find my new code tomorrow morning.

Ciao,
Geert
0
fabiano petroneAuthor Commented:
Hi, Geert
yes, it is  the "bibliothech.udine@uniud.it [... ]" that I want to change

Thanks a lot,

Fabiano
0
Geert BormansInformation ArchitectCommented:
some confusing experiences I got here.
I don't think that the XSLT you sent me are the ones you use
It seems you have been messing with the SenderReceiver.Xsl prior to sending it

Note there obviously is a post process that replaces all @@dear@@ constructs into a language specific text
For me that always is a warning bell, since obviously some process touches the result after the transform

Anyhow, I think you should look at the attached screenshot and see what needs changing
my-result.jpg
0
fabiano petroneAuthor Commented:
Hi, Geert
Here some answers to your previous question:
1)I've left SenderReceiver.Xsl untouched
2)@@ are placeholders for values that the software we're using "catches" from another configuration location.
please see the example screenshot for the @@contact_us@@.

Bye
Fabiano
contactus.jpg
0
Geert BormansInformation ArchitectCommented:
thanks Fabiano,
2) that is what I assumed, nice approach, just make sure that "software" has no weird side effects
1) strange. Can you explain why I get the output I am getting (I use the source file you sent) Which stylesheet is the starting point of your transform? I might be missing a main driver
0
fabiano petroneAuthor Commented:
Hi, Geert
thanks for the quick reply.
I can't explain why you've this output...I know only that @@ are placeholders for values that are "configured" in another location of the application.
I can access this config page, but regarding my problem (the header email) I can configure only one for all the libraries.
My personal 2 cents of an XML newbie...that's not pure XSLT but a "mixed monster" like a chimera on which some parts are XSLT-driven (like the mail in the body of the letter...see your example) and other NOT, and sadly the mail header address is in this latter group.
But don't worry...also your expert agreement with my diagnosis is a great contribution for me...so if you agree with me I'll surely accept your solution of inserting the right mail in the body of the letter.
Thanks,
Fabiano
0
Geert BormansInformation ArchitectCommented:
Hi Fabiano,
I tend to agree that the issue of your problem is not in the XSLT
However, you might be able to fake a solution by having
@@mail1@@ for the first email address, @@mail2@@ for the next
and put them all in the config, that is not necisarrily worse than coding them in the XSLT
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fabiano petroneAuthor Commented:
Hi,  Geert
Thanks a lot for your qualified opinion...sadly I can't add more @@ variables but everyway I'll use your solution of writing the exact email address inside the single mail bodies,  emphatizing it with bold & red-coloured characters

Bye,
Fabiano
0
Geert BormansInformation ArchitectCommented:
welcome and good luck
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
XML

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.