Convert XML to Fixed Length
Questions about XML that are not covered by the other forums should go here.
Convert XML to Fixed Length
Hello.
Wondering if it's possible to convert an XML document to a fixed length file via an XSLT. Any examples out there?
Do I need a specific parser such Saxon8 or is a 1.0 Processor good enough?
Thank You.
Wondering if it's possible to convert an XML document to a fixed length file via an XSLT. Any examples out there?
Do I need a specific parser such Saxon8 or is a 1.0 Processor good enough?
Thank You.
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Post by sorin_ristache »
Hello,
You did not specify how the fixed length output file depends on the (variable length ?) input XML file. What should the transformation do ? Without knowing more about this it is impossible to help you. Can you post small samples of the input XML file and the output file ?
Regards,
Sorin
You did not specify how the fixed length output file depends on the (variable length ?) input XML file. What should the transformation do ? Without knowing more about this it is impossible to help you. Can you post small samples of the input XML file and the output file ?
Regards,
Sorin
Hi sorin,sorin wrote:Hello,
You did not specify how the fixed length output file depends on the (variable length ?) input XML file. What should the transformation do ? Without knowing more about this it is impossible to help you. Can you post small samples of the input XML file and the output file ?
Regards,
Sorin
you can try this out for transfrming a XML file to a fixed length file.
EX:if u want to convert EMP_NO= "12 " to make it to the length of 10.
ur output will be "0000000012".
Here is the code.
Use this template
<xsl:template name="append-pad-left">
<xsl:param name="padChar"> </xsl:param>
<xsl:param name="padVar"/>
<xsl:param name="length"/>
<xsl:choose>
<xsl:when test="string-length($padVar) < $length">
<xsl:call-template name="append-pad-left">
<xsl:with-param name="padChar" select="$padChar"/>
<xsl:with-param name="padVar" select="concat($padVar,$padChar)"/>
<xsl:with-param name="length" select="$length"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="substring($padVar,1,$length)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
and call this template wherever u need.
<xsl:call-template name="append-pad-left">
<xsl:with-param name="padChar" select="' '"></xsl:with-param>
<xsl:with-param name="padVar" select="EMP_NO"></xsl:with-param>
<xsl:with-param name="length" select="10"/>
</xsl:call-template>
Thanks
Gaya
Return to “General XML Questions”
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