• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 780
  • Last Modified:

insert Embed HREF attribute in XSL

I read most entries from a search in this TOPIC area for href insertions in XSL but mine is a bit different. This is not an
<a href...> link... but an href attribute *inside* an embed tag which is in the XSL file as follows:

      <embed src="/audio/images/playQuicktime.mov" pluginspage="http://www.apple.com/quicktime/download/" width="200" height="35" align="top" controller="false" loop="false" autoplay="false" href=xsl:value-of select="audio_transcript/header/audio_filename" target="myself" class="audio1" />

where I am trying to select the value of <audio_filename> in my XML doc and insert it into the embed tag href atttribute.

gives me, in FireFox:

XML Parsing Error: not well-formed
Location: http://www.himalayanacademy.com/audio/cybertalks/satguruspeaks.xsl
Line Number 55, Column 197:                                    <embed src="/audio/images/playQuicktime.mov" pluginspage="http://www.apple.com/quicktime/download/" width="200" height="35" align="top" controller="false" loop="false" autoplay="false" href=xsl:value-of select="audio_transcript/header/audio_filename" target="myself" class="audio1" />


My XML file looks like this....

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="../../satguruspeaks.xsl"?>
<audio_transcript>
 <header>
  <audio_filename>bd_2004-11-28_prejudice-free.mp3</audio_filename>
  <date_given>11-28-2004</date_given>
  <given_by>Bodhinatha</given_by>
  <subject>Prejudice Free Consciousness</subject>
  <category>Hinduism and Tradition</category>
  <duration>15 min, 19 secs</duration>
  <given_location></given_location>
  <transcribed_by>Asha Alahan</transcribed_by>
  <description>
<![CDATA[
We are not born with prejudice but prejudice is learned, there's a need to teach tolerance, joyous reverence for diversity. Mahatma Gandhi, Dr. Martin Luther King, Swami Chinmayananda each spoke of the Hindu principles of ahimsa-non violence, tolerance, high- minded values.

]]></description>
 </header>
 <transcript_text>
  <![CDATA[

Good Morning Everyone.
Continuing this morning on our series from Mauritius. [SNIP]

  ]]>
  </transcript_text>
 </audio_transcript>

Thanks!

Sivakatirswami
0
Sivakatirswami
Asked:
Sivakatirswami
  • 12
  • 6
1 Solution
 
b1xml2Commented:
href="{audio_transcript/header/audio_filename}"

use the curly braces and you can access the document nodes.
0
 
b1xml2Commented:
first solution implicit
===============
<embed src="/audio/images/playQuicktime.mov" pluginspage="http://www.apple.com/quicktime/download/" width="200" height="35" align="top" controller="false" loop="false" autoplay="false" href="{audio_transcript/header/audio_filename}" target="myself" class="audio1" />

second solution explicit
==============
<embed src="/audio/images/playQuicktime.mov" pluginspage="http://www.apple.com/quicktime/download/" width="200" height="35" align="top" controller="false" loop="false" autoplay="false" target="myself" class="audio1">
<xsl:attribute name="href"><xsl:value-of select="audio_transcript/header/audio_filename" /></xsl:attribute>
</embed>

0
 
SivakatirswamiAuthor Commented:
Thanks b1xml2

When I see two methods, naturally the theoretical question arises, which is better to use and why, or, when it is better to use one over the other  and why?

But, in any case, neither works... :-(

OK testing first to make sure everything is green:

i have: <p><b>Audio FileName: </b><xsl:value-of select="audio_transcript/header/audio_filename" /></p>

in the XSL file for

http://www.himalayanacademy.com/audio/cybertalks/bodhinatha/2005/bd_2004-11-28_prejudice-free.xml

And it returns, as it should the simple file name: OK check one is good...:

bd_2004-11-28_prejudice-free.mp3

OK just to make sure everything is working  

test one: hard code the link, just to be sure all systems are go:

<embed src="/audio/images/playQuicktime.mov" pluginspage="http://www.apple.com/quicktime/download/" width="200" height="35" align="top" controller="false" loop="false" autoplay="false" href="/audio/cybertalks/bodhinatha/2005/bd_2004-11-28_prejudice-free.mp3" target="myself" class="audio1" />

Yes! this works... so, basic framework is funcationing. Check Two is good...so, we know, the XSL is failing, not anything else:

OK try this now (implicit solution)


      <embed src="/audio/images/playQuicktime.mov" pluginspage="http://www.apple.com/quicktime/download/" width="200" height="35" align="top" controller="false" loop="false" autoplay="false" href="/audio/cybertalks/bodhinatha/2005/{audio_transcript/header/audio_filename}" target="myself" class="audio1" />

Does not work.... In firefox, I am unable to determine the "source" code after transformation. An attempt to view source only shows the original XML file.

as for the explicit method, I don't know how to cat the path stem (root relative in this case: /audio/cybertalks/bodhinatha/2005/"  to the file name, but this  following guess-attempt does not give a parsing error, yes also does not work:

<embed src="/audio/images/playQuicktime.mov" pluginspage="http://www.apple.com/quicktime/download/" width="200" height="35" align="top" controller="false" loop="false" autoplay="false" target="myself" class="audio1"><xsl:attribute name="href">/audio/cybertalks/bodhinatha/2005/<xsl:value-of select="audio_transcript/header/audio_filename" /></xsl:attribute>
</embed>

There is nothing particularly confidential in these directories, so I turned option indices on and you can view my initial hacks here:

http://www.himalayanacademy.com/audio/cybertalks/  (and see the current "satguruspeaks.xsl" file)

http://www.himalayanacademy.com/audio/cybertalks/bodhinatha/

Thanks!

ps If I could increase the points to 1000 I would because I really need to get this working... otherwise I have to abandon this XSL strategy and dynamically build these pages with a CGI... which is doable, but I would like them to work as flat files, if at all possible.





0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
b1xml2Commented:
looking at it now.
0
 
b1xml2Commented:
The following Xml Fragment (the transformed data) is of interest to you
==============================================

<div id="audio_links">
Choose one of the following to listen:
<br>
<embed src="/audio/images/playQuicktime.mov" pluginspage="http://www.apple.com/quicktime/download/" width="200" height="35" align="top" controller="false" loop="false" autoplay="false"
      target="myself" class="audio1" href="/audio/cybertalks/bodhinatha/2005/ bd_2004-11-28_prejudice-free.mp3"></embed><br>
</div>
<div id="other_languages">
<b>Links and icons for other languages go here... we still have to work out the functional spec for this aspect....</b>
</div>

Please note that your href has an additional space before the file name and that's because you have an additional space in your Xml document
  <audio_filename> bd_2004-11-28_prejudice-free.mp3</audio_filename>
0
 
SivakatirswamiAuthor Commented:
oops! extra space.. right, OK I fixed that, and yes it works.. thanks...

Two final questions:

1) how did you view source on the transformed data?
2) By what criteria does one decide to use the {implicit} vs explicit (fully declared) forms?
0
 
b1xml2Commented:
example of client-side Xml Transformation:
 1. create an empty html page
2. copy and paste the following:
3. change the xml and xslt locations accordingly

<script langauge="javascript">
var oXml = new ActiveXObject("Msxml2.DOMDocument");
var oXslt = new ActiveXObject("Msxml2.DOMDocument");
var oResult = new ActiveXObject("Msxml2.DOMDocument");
var oStylesheet = new ActiveXObject("Msxml2.DOMDocument");
oXml.async = oXslt.async = oResult.async = false;
oStylesheet.async = true;
oStylesheet.load("res://msxml3.dll/defaultss.xsl");
oXml.load("May/data3.xml");
oXslt.load("May/data3.xslt");
window.onload = init;
function init()
{
     
     if (oStylesheet.readyState != "4")
     {
          window.setTimeout("init();",200);
     }
     else
     {
          oXml.transformNodeToObject(oXslt,oResult);
          document.write(oResult.transformNode(oStylesheet));
     }
}

</script>
0
 
b1xml2Commented:
That applies when the output is marked as XML

<xsl:output method="xml" version="1.0" />
0
 
b1xml2Commented:
Explicit transformation is where you transform the data and show the results only. This can be done on various platforms..
you change this to your xml and xslt paths
oXml.load("May/data3.xml");
oXslt.load("May/data3.xslt");

This can be done in ASP.NET where the browser sees only the HTML and does not see the Xml nor the Xslt
0
 
b1xml2Commented:
the use of the xml-stylesheet processing instruction allows for much of the processing to be done by the client. The down-side is that your Xml will be exposed for others to copy and then apply their own Xslt and present the data accordingly.

Also, it is specific to MSIE 5+ and also the Mozilla browser(there are some quirks).

It is better to have the transformation done server-side and never show the Xml and Xslt to the public. The public only sees the output.
0
 
b1xml2Commented:
as to the code, i prefer the implicit as a rule. It is shorter in syntax
0
 
SivakatirswamiAuthor Commented:
Aloha, b1xml2

Thanks, I accepted your first solution, since it answered the problem (the space in the file name being ancillary to the issue of how to declare the XSL insertion)

But your above answer is a bit over my head... and doesn't shed any light directly (for me at least) on why or when one or the other of these two are preferred in a context for web delivery

1) (explicit) <xsl:attribute name="href">/audio/cybertalks/bodhinatha/2005/<xsl:value-of select="audio_transcript/header/audio_filename" /></xsl:attribute>

vs

2) (implicit) href="/audio/cybertalks/bodhinatha/2005/{audio_transcript/header/audio_filename}"

Unless I infer from your phrase "This can be done on various platforms.) means that 1) (explicit) works in diverse contexts while 2) implicit may not serve in some contexts...

I guess I worry, since I am not well trained, about whether I should be using one or the other when I don't know why I should or not, use one or the other. Anyway, thank you...

Sivakatirswami ("One who doesn't like to fly blind -:)"
0
 
b1xml2Commented:
implicit!
0
 
SivakatirswamiAuthor Commented:
Apparently our posts are crossing each other...

as for "exposure of the XML" I'm not sure that's a problem here, because what is displayde and what is in the XML style sheet are a virtual match other than the "skin" comprised of the html mark up related CSS, in  the XSL stylesheet processing. So, the "data" is exposed for copying one way or another anyway, but, yes, I see how this could become even "worse" than having someone leech your html pages into their frames (where at least your web site style, look and feel continues to appear in their frames) in this case, they could completely apply their own skin to the data and hotlink the XML file and the end user of the other site would never know the difference.  So, there are cases where that could be a problem. Hot linking our stuff is already a problem.....

ok implicit, explicit if it is simply a matter or code style, then yet implicit is short and sweet.

I'll look into other options for server side transformation. We use Revolution for all server side processing and it should not be difficult.
0
 
b1xml2Commented:
=)
0
 
SivakatirswamiAuthor Commented:
"It is better to have the transformation done server-side and never show the Xml and Xslt to the public. The public only sees the output."

Well this case is closed, but I have this nagging, on-going question on dynamically generated content, which this server-side transformation would be: does Google index these pages? They have disclaimers on their FAQ for web masters about this issue and it leaves one worried that if we use a CGI for the transformation, Google will balk at crawling the page with links to this dynamically generated content.

skts
0
 
b1xml2Commented:
With ASP and ASP.NET platforms, we have virtual pages
for example: http://www.myserver.com/display.aspx?id=1

is shown as http://www.myserver.com/display/page1.aspx but from the URL the appropriate objects are deduced and make it such that it is as though http://www.myserver.com/display.aspx?id=1 was called by the client. This path re-writing is available in ASP and has been made so much powerful in ASP.NET. You could try looking in this direction.
0
 
SivakatirswamiAuthor Commented:
path re-writing: Thank you for the suggestion, we'll look into it
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 12
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now