• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

HTML tag within XML

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to use HTML tags within XML file which is parsed by XSL on server. But in result it displays HTML tags as it is, those HTML tags which i want to be interpreted without mentioning them in XSL file should be interpreted as HTML tags. Could anybody tell me the solution for this problem.
e.g., in XML document I have <Title>This is a sample title named <B>Samle Title</B></Title>. i mention Title tag in XSL but cann't use <B> tag, since this part is generated dynamically.
i hope i could express my question clearly.
any help....

------------------
[This message has been edited by tanya (edited July 20, 2001).]
 
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tanya!
If what you want is to copy HTML tags from XML document to output HTML, then you can write a generic template, which will match HTML tags and copy them:
<xsl:template match="B | P | ... "> <!�put here HTML tags you use -->
<xsl:copy-of select="."/>
</xsl:template>
The whole stylesheet:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<xsl:apply-templates select="./Title"/>
</body>
</html>
</xsl:template>
<xsl:template match="B | P ">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>

output:
<html>
<body>This is a sample title named <B>Samle Title</B>
</body>
</html>
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tanya,
Your name does not comply with the JavaRanch naming policy. Please spare a moment and re-register with a name that meets the requirements.
Thanks!
Ajith
 
tanya
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mapraputa Is:
Hi Tanya!
If what you want is to copy HTML tags from XML document to output HTML, then you can write a generic template, which will match HTML tags and copy them:
<xsl:template match="B | P | ... "> <!�put here HTML tags you use -->
<xsl:copy-of select="."/>
</xsl:template>
[b]The whole stylesheet:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<xsl:apply-templates select="./Title"/>
</body>
</html>
</xsl:template>
<xsl:template match="B | P ">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>

output:
<html>
<body>This is a sample title named <B>Samle Title</B>
</body>
</html>[/B]


------------------------------
I have tried it using in many ways but somehow it's not working at my end.
I tried using
<xsl:for-each select="Item">
<xsl:template match="B">
<xsl:copy>
<xsl:apply-templates"/>
</xsl:copy>
</xsl:template>
and then
<xsl:choose>
<xsl:when test="contains(@Type, 'Paragraph')">

<tr><td> </td></tr>

<tr>
<td colspan="2">
<dl>
<dd>
<xsl:apply-templates select="."/>
</dd>
</dl>
</td>
</tr>

</xsl:when>
</xsl:choose>
</xsl:for-each>
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a million for your valuable response, it did work now, may be i was wrong somewhere.
Thanks again
 
Tanya Rawat
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually the problem was it didn't work if i use apply-templates instead it is fine with value-of here :
<xsl:value-of select="." />
 
Tanya Rawat
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One more thing what if i want to use <font face="arial" size="2"> also.
Thanks
 
Tanya Rawat
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Guys ! i have got the answer myself.....

[This message has been edited by Tanya Rawat (edited July 23, 2001).]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic