A different type of xml
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 1
- Joined: Tue Jan 23, 2007 5:54 pm
A different type of xml
I have an auto generated xml from java something like this
<?xml version="1.0" encoding="UTF-8"?>
<java version="1.5.0_09" class="java.beans.XMLDecoder">
<object class="src.UserDetails">
<void property="firstNameDataText">
<string>Nombre (s)</string>
</void>
<void property="lastNameDataText">
<string>Apellidos</string>
</void>
<!-- Many More Fields -->
</object>
</java>
In PDF I want to use table where firstName and LastName will be in same row...
The XSL I wrote is as follows
<xsl:template match="void">
<fo:table table-layout="fixed" width="75%" border="0.2pt solid black">
<fo:table-column column-width="proportional-column-width(1)"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell>
<xsl:if test= "@property='firstNameDataText'">
<fo:block font-size="5pt"
font-family="sans-serif"
color="black"
text-align="left">
<xsl:value-of select ="string"/>
</fo:block>
</xsl:if>
</fo:table-cell>
<fo:table-cell>
<xsl:if test= "@property='lastNameDataText'">
<fo:block font-size="5pt"
font-family="sans-serif"
color="black">
<xsl:value-of select ="string"/>
</fo:block>
</xsl:if>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</xsl:template>
The problem here i am facing is tht, it is creating table everytime it encounters void tag. But every field in my xml is identified by attribute name and not tag name.
<?xml version="1.0" encoding="UTF-8"?>
<java version="1.5.0_09" class="java.beans.XMLDecoder">
<object class="src.UserDetails">
<void property="firstNameDataText">
<string>Nombre (s)</string>
</void>
<void property="lastNameDataText">
<string>Apellidos</string>
</void>
<!-- Many More Fields -->
</object>
</java>
In PDF I want to use table where firstName and LastName will be in same row...
The XSL I wrote is as follows
<xsl:template match="void">
<fo:table table-layout="fixed" width="75%" border="0.2pt solid black">
<fo:table-column column-width="proportional-column-width(1)"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell>
<xsl:if test= "@property='firstNameDataText'">
<fo:block font-size="5pt"
font-family="sans-serif"
color="black"
text-align="left">
<xsl:value-of select ="string"/>
</fo:block>
</xsl:if>
</fo:table-cell>
<fo:table-cell>
<xsl:if test= "@property='lastNameDataText'">
<fo:block font-size="5pt"
font-family="sans-serif"
color="black">
<xsl:value-of select ="string"/>
</fo:block>
</xsl:if>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</xsl:template>
The problem here i am facing is tht, it is creating table everytime it encounters void tag. But every field in my xml is identified by attribute name and not tag name.
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Post by sorin_ristache »
Hello,
Your stylesheet creates a fo:table for each void element in the XML input document. To create a fo:table for each object element and a fo:table-row for each void element you can use the following templates in your stylesheet.
Regards,
Sorin
Your stylesheet creates a fo:table for each void element in the XML input document. To create a fo:table for each object element and a fo:table-row for each void element you can use the following templates in your stylesheet.
Code: Select all
<xsl:template match="object">
<fo:table table-layout="fixed" border="0.2pt solid black">
<fo:table-column column-width="proportional-column-width(1)"/>
<fo:table-body>
<xsl:apply-templates select="void"/>
</fo:table-body>
</fo:table>
</xsl:template>
<xsl:template match="void">
<fo:table-row>
<fo:table-cell>
<xsl:if test= "@property='firstNameDataText'">
<fo:block font-size="5pt"
font-family="sans-serif"
color="black"
text-align="left">
<xsl:value-of select ="string"/>
</fo:block>
</xsl:if>
</fo:table-cell>
<fo:table-cell>
<xsl:if test= "@property='lastNameDataText'">
<fo:block font-size="5pt"
font-family="sans-serif"
color="black">
<xsl:value-of select ="string"/>
</fo:block>
</xsl:if>
</fo:table-cell>
</fo:table-row>
</xsl:template>
Sorin
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