Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 29th, 2004, 05:25 AM
Authorized User
 
Join Date: Mar 2004
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I use the xsl by embedding it to xml with this line:
<?xml-stylesheet type="text/xsl" href="personals.xsl" ?>

This is the xml code fragment: http://private.livas.lv/jaanise/xml-code.png.
This is the document when viewed in IE: http://private.livas.lv/jaanise/xml-xsl.png.
This is the document without the embbed xsl when viewed in IE: http://private.livas.lv/jaanise/xml-plain.png.

You see - I would like an image to appear instead of the code (and the same with link and line break codes I have further).

Thanks,
Janis

 
Old August 29th, 2004, 06:46 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If what you want is to show a picture in your html page, you can use this:

<personals>
  <kategorija>
    <biedrs>
      <foto><img src="d:\test1.jpg"/></foto>
      <niks>test</niks>
    </biedrs>
  </kategorija>
</personals>

In your xsl, use '..copy of..' like this:

<html>
<body>
<table border="1"><tr>
  <td><xsl:copy-of select="personals/kategorija/biedrs/foto"/></td>
  <td><xsl:value-of select="personals/kategorija/biedrs/niks"/></td>
</tr></table>
</body>
</html>
 
Old August 29th, 2004, 08:25 AM
Authorized User
 
Join Date: Mar 2004
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you very much, it works! :D

Sorry, joe, for as a beginner I apparently didn't ask the right questions...

Janis

 
Old August 30th, 2004, 10:43 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

I'm glad it's fixed, but you did ask how to put plain text in between text and I suggested CDATA. So when you write:
Code:
<foto><![CDATA[<img...
Then the <img is not markup it's just text. remolve the CDATA deliters if yoou need to transform it via xslt.



--

Joe (Co-author Beginning XML, 3rd edition)
 
Old January 2nd, 2007, 05:29 AM
Registered User
 
Join Date: Dec 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I realize this post is dated, but it answered an important question I had: how to embed a reference to an image in XML.

I have another question: Referring to the text stated by Birger, that is,

<html>
<body>
<table border="1"><tr>
  <td><xsl:copy-of select="personals/kategorija/biedrs/foto"/></td>
  <td><xsl:value-of select="personals/kategorija/biedrs/niks"/></td>
</tr></table>
</body>
</html>

how would one write it using a template call?

One more question: Am I the only one that finds templates somewhat mysterious in their operation?

 
Old January 2nd, 2007, 06:29 AM
Registered User
 
Join Date: Dec 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry, but I just now realized that my question probably belongs in the XSLT forum.

 
Old January 2nd, 2007, 06:45 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>how would one write it using a template call?

You could, if you wanted, replace

<xsl:value-of select="personals/kategorija/biedrs/niks"/>

with

<xsl:apply-templates select="personals/kategorija/biedrs/niks"/>

and

<xsl:template match="niks">
  <xsl:value-of select="."/>
</xsl:template>

>Am I the only one that finds templates somewhat mysterious in their operation?

No, it's a common learning problem, especially for programmers coming from a more structured environment without previous experience of text processing. It applies also to other event-based programming models, for example GUI programming and SAX parsing applications. Programmers like to be in control, they like to call the system, not have the system call them. But event-based (or rule-based) programming is a very powerful model when you don't know in advance what the order of events is going to be, or how it might change in the future: that's why it works particularly well with semi-structured data.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to find text within range of two tags dipsut XSLT 3 May 25th, 2007 04:27 PM
Adding a <p> in text that has no xml tags dzisaacs XSLT 1 November 1st, 2005 02:14 PM
Extracting text between <body> tags sumedha HTML Code Clinic 2 June 29th, 2005 02:37 PM
Renaming with XML tags? johrik XSLT 1 February 12th, 2004 03:49 PM
Extracting text between tags aware Classic ASP Professional 4 December 24th, 2003 04:25 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.