File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes HTML tag within XML Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "HTML tag within XML" Watch "HTML tag within XML" New topic
Author

HTML tag within XML

tanya
Greenhorn

Joined: Jul 20, 2001
Posts: 2
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).]
Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
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>

Uncontrolled vocabularies
"I try my best to make *all* my posts nice, even when I feel upset" -- Philippe Maquet
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5781
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


Open Group Certified Master IT Architect.
Sun Certified Architect(SCEA).
tanya
Greenhorn

Joined: Jul 20, 2001
Posts: 2
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>
Tanya Rawat
Ranch Hand

Joined: Jul 23, 2001
Posts: 31
Thanks a million for your valuable response, it did work now, may be i was wrong somewhere.
Thanks again
Tanya Rawat
Ranch Hand

Joined: Jul 23, 2001
Posts: 31
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

Joined: Jul 23, 2001
Posts: 31
One more thing what if i want to use <font face="arial" size="2"> also.
Thanks
Tanya Rawat
Ranch Hand

Joined: Jul 23, 2001
Posts: 31
Thanks Guys ! i have got the answer myself.....

[This message has been edited by Tanya Rawat (edited July 23, 2001).]
 
 
subject: HTML tag within XML
 
Threads others viewed
Displaying an image from xml source element
It's boring, XSLT ...
How to process a html tag in xslt?
XSL and XSLT
HTML Tags in XML file
IntelliJ Java IDE