Trying to display tagname
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 7
- Joined: Sat Nov 10, 2007 11:32 am
- Location: Vancouver, BC
Trying to display tagname
Post by lou_boumian »
I am a translator, not a programmer, and I am completely new to this game.
I have several XML docs of the form:
Where I have to introduce the French translation of the English String (value of ENG) into the value of FRE.
I am trying to display these files as tables which will be much easier to handle.
I figured out how to display a table with 2 columns titled:
English and French
with the following XLS file:
But I would like to have a first column displaying the tagname of the first child :
checklist_c1, checklist_c2, etc...
I have tried with the following code :
...but it does not work.
(I realize that I don't realy know what I am doing here...)
If anybody has a suggestion, that would help!
Thanks!
Pascal
I have several XML docs of the form:
Code: Select all
<content>
<checklist_c1>
<ENG>Confirmation</ENG>
<CHI></CHI>
<CHT></CHT>
<RUS></RUS>
<POL></POL>
<FIL></FIL>
<FRE></FRE>
<VIE></VIE>
<SPA></SPA>
<PER></PER>
<PAN></PAN>
<HIN></HIN>
</checklist_c1>
<checklist_c2>
<ENG>You need the following three pieces of information as proof you have completed this orientation. Please select one of the options below, then click the</ENG>
<CHI></CHI>
<CHT></CHT>
<RUS></RUS>
<POL></POL>
<FIL></FIL>
<FRE></FRE>
<VIE></VIE>
<SPA></SPA>
<PER></PER>
<PAN></PAN>
<HIN></HIN>
</checklist_c2>
....
</content>
I am trying to display these files as tables which will be much easier to handle.
I figured out how to display a table with 2 columns titled:
English and French
with the following XLS file:
Code: Select all
<?xml version="1.0" encoding="iso-8859-1" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="node()">
<html>
<body>
<table border="2">
<tr>
<th>English</th>
<th>French</th>
</tr>
<xsl:for-each select="content/*">
<tr>
<td><xsl:value-of select="ENG" /></td>
<td><xsl:value-of select="FRE" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
checklist_c1, checklist_c2, etc...
I have tried with the following code :
Code: Select all
<?xml version="1.0" encoding="iso-8859-1" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="node()">
<html>
<body>
<table border="2">
<tr>
<th>Entry #</th>
<th>English</th>
<th>French</th>
</tr>
<xsl:for-each select="content/*">
<tr>
<td><xsl:value-of select="name()" /></td>
<td><xsl:value-of select="ENG" /></td>
<td><xsl:value-of select="FRE" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
(I realize that I don't realy know what I am doing here...)
If anybody has a suggestion, that would help!
Thanks!
Pascal
-
- Posts: 7
- Joined: Sat Nov 10, 2007 11:32 am
- Location: Vancouver, BC
Post by lou_boumian »
Thanks for your suggestion jkmyoung.
When I use my xsl namespace version, I get this error:
When I use my xsl namespace version, I get this error:
When I use your name space instead of mine, I get this error:The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
--------------------------------------------------------------------------------
Unknown method. -->name()<--
The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
--------------------------------------------------------------------------------
Required attribute 'version' is missing.
-
- Posts: 7
- Joined: Sat Nov 10, 2007 11:32 am
- Location: Vancouver, BC
-
- Posts: 7
- Joined: Sat Nov 10, 2007 11:32 am
- Location: Vancouver, BC
Post by lou_boumian »
How would you write the namespace then?You probably need version="1.0" in your stylesheet node.
I tried <xmlns:xsl="http://www.w3.org/1999/XSL/Transform version="1.0"> and it gives me this error:
The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
--------------------------------------------------------------------------------
A name contained an invalid character. Error processing resource 'file:///D:/checklist_FRE.xml
<xmlns:xsl="http://www.w3.org/1999/XSL/Transform version="1.0">
----------^
-
- Posts: 7
- Joined: Sat Nov 10, 2007 11:32 am
- Location: Vancouver, BC
Post by lou_boumian »
Thanks,
with this name space, I have no error but I just get this table:
-------------------------------------
| Entry # | English | French |
-------------------------------------
| Entry # | English | French |
-------------------------------------
with this name space, I have no error but I just get this table:
-------------------------------------
| Entry # | English | French |
-------------------------------------
| Entry # | English | French |
-------------------------------------
-
- Posts: 7
- Joined: Sat Nov 10, 2007 11:32 am
- Location: Vancouver, BC
Post by lou_boumian »
So I have this xml file:
an this xsl file:
and I only get the table shown in previous message:
I tried in IE7 Netscape 8. Same result for both.
Thanks jkmyoung for the tip about the namespace. Anybody else has a suggestion?
Code: Select all
<?xml version="1.0" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="content.xsl"?>
<content>
<checklist_c1>
<ENG>Confirmation</ENG>
<CHI></CHI>
<CHT></CHT>
<RUS></RUS>
<POL></POL>
<FIL></FIL>
<FRE></FRE>
<VIE></VIE>
<SPA></SPA>
<PER></PER>
<PAN></PAN>
<HIN></HIN>
</checklist_c1>
<checklist_c2>
<ENG>You need the following three pieces of information as proof you have completed this orientation. Please select one of the options below, then click the</ENG>
<CHI></CHI>
<CHT></CHT>
<RUS></RUS>
<POL></POL>
<FIL></FIL>
<FRE></FRE>
<VIE></VIE>
<SPA></SPA>
<PER></PER>
<PAN></PAN>
<HIN></HIN>
</checklist_c2>
</content>
Code: Select all
<?xml version="1.0" encoding="iso-8859-1" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="node()">
<html>
<body>
<table border="2">
<tr>
<th>Entry #</th>
<th>English</th>
<th>French</th>
</tr>
<xsl:for-each select="content/*">
<tr>
<td><xsl:value-of select="name()" /></td>
<td><xsl:value-of select="ENG" /></td>
<td><xsl:value-of select="FRE" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
instead of the desired result:-------------------------------------
| Entry # | English | French |
-------------------------------------
| Entry # | English | French |
-------------------------------------
Code: Select all
---------------------------------------------------
| Entry # | English | French |
---------------------------------------------------
| checklist_c1 | Confirmation | |
---------------------------------------------------
| checklist_c2 | You need ...bla bla | |
---------------------------------------------------
Thanks jkmyoung for the tip about the namespace. Anybody else has a suggestion?
-
- Posts: 7
- Joined: Sat Nov 10, 2007 11:32 am
- Location: Vancouver, BC
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service