Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I would like: <para name="1"

Status
Not open for further replies.

mountainbiker

Programmer
Aug 21, 2002
122
GB
I would like:
[tt]
<para name=&quot;1&quot;>
this is a test of <et>emphanized</et> text.
</para>
<para name=&quot;2&quot;>
this is another test of <et>emphanized</et> text.
</para>
[/tt]

to transform to:
<p>this is a test of <b>emphanized</b> text.</p>
<p>this is another test of <b>emphanized</b> text.</p>
 
Sure, you can use XSLT to build that output. See the FAQ's here for this forum and also there are other XML based sites in the &quot;Partners&quot; box at the bottom of the left frame.

-pete
 
XML:
<doc>
<Para>
Here some <EmphasizedText emphasisType='b'>words</EmphasizedText> are
<EmphasizedText emphasisType='i'>recursively
<EmphasizedText emphasisType='b'>
emphasized
</EmphasizedText>
</EmphasizedText>.
However, this word is <Superscript>not</Superscript>. This next word is <EmphasizedText>bold</EmphasizedText>. This word is <EmphasizedText emphasisType='u'>underlined</EmphasizedText>.
</Para>
</doc>


XSL:
<xsl:template match=&quot;doc&quot;>
<html>
<head>
<title>A Document</title>
</head>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>

<xsl:template match=&quot;Para&quot;>
<p><xsl:apply-templates/></p>
</xsl:template>

<xsl:template match=&quot;EmphasizedText | Superscript | Subscript&quot;>
<xsl:choose>
<xsl:when test=&quot;not(@emphasisType) or @emphasisType = 'b'&quot;>
<b><xsl:apply-templates/></b>
</xsl:when>
<xsl:when test=&quot;@emphasisType = 'i'&quot;>
<i><xsl:apply-templates/></i>
</xsl:when>
<xsl:when test=&quot;@emphasisType = 'u'&quot;>
<u><xsl:apply-templates/></u>
</xsl:when>
<xsl:when test=&quot;name() = 'Superscript'&quot;>
<u><xsl:apply-templates/></u>
</xsl:when>
<xsl:when test=&quot;name() = 'Subscript'&quot;>
<u><xsl:apply-templates/></u>
</xsl:when>
<xsl:eek:therwise>
<xsl:apply-templates/>
</xsl:eek:therwise>
</xsl:choose>
</xsl:template>
 
This latter example is not retaining spaces if sandwiched between an ending tag and starting tag, i.e., [tt]... </EmphasizedText> <EmphasizedText emphasisType='b'> ...[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top