How do I display HeightFeet element?
Here should go questions about transforming XML with XSLT and FOP.
How do I display HeightFeet element?
Based on my xml code, I want to convert the HeightFeet number into inches.
I also want to check that the HeightFeet is not less than 48 inches and not greater than 95 inches.
How do I do this?
Can someone help me?
My xml code
Desired output
Output I am getting
xslt code
I also want to check that the HeightFeet is not less than 48 inches and not greater than 95 inches.
How do I do this?
Can someone help me?
My xml code
Code: Select all
<Party ID="1116666" InternalPartyID="1610656384">
<Gender Word="F">Female</Gender>
<HeightFeet>5</HeightFeet>
<WeightPounds>130</WeightPounds>
<EyeColor Word="BLU">Blue</EyeColor>
</Party>
Code: Select all
<nc:PersonHeightMeasure>
<nc:MeasureText>60</nc:MeasureText>
<nc:MeasureUnitText>inches</nc:MeasureUnitText>
<nc:LengthUnitCode>INH</nc:LengthUnitCode>
</nc:PersonHeightMeasure>
Code: Select all
<nc:PersonHeightMeasure>
<nc:MeasureText>NaN</nc:MeasureText>
<nc:MeasureUnitText>inches</nc:MeasureUnitText>
<nc:LengthUnitCode>INH</nc:LengthUnitCode>
</nc:PersonHeightMeasure>
Code: Select all
<nc:PersonHeightMeasure>
<nc:MeasureText>
<xsl:choose>
<xsl:when test="HeightFeet">
<xsl:value-of select="(HeightFeet*12) + HeightInches "/>
</xsl:when>
</xsl:choose>
</nc:MeasureText>
<nc:MeasureUnitText>
<xsl:text>inches</xsl:text>
</nc:MeasureUnitText>
<nc:LengthUnitCode>
<xsl:text>INH</xsl:text>
</nc:LengthUnitCode>
</nc:PersonHeightMeasure>
Re: How do I display HeightFeet element?
winkimjr2 wrote:Based on my xml code, I want to convert the HeightFeet number into inches.
I also want to check that the HeightFeet is not less than 48 inches and not greater than 95 inches.
How do I do this?
Can someone help me?
My xml codeDesired outputCode: Select all
<Party ID="1116666" InternalPartyID="1610656384">
<Gender Word="F">Female</Gender>
<HeightFeet>5</HeightFeet>
<HeightInches>5</HeightInches>
<WeightPounds>130</WeightPounds>
<EyeColor Word="BLU">Blue</EyeColor>
</Party>Output I am gettingCode: Select all
<nc:PersonHeightMeasure>
<nc:MeasureText>60</nc:MeasureText>
<nc:MeasureUnitText>inches</nc:MeasureUnitText>
<nc:LengthUnitCode>INH</nc:LengthUnitCode>
</nc:PersonHeightMeasure>xslt codeCode: Select all
<nc:PersonHeightMeasure>
<nc:MeasureText>NaN</nc:MeasureText>
<nc:MeasureUnitText>inches</nc:MeasureUnitText>
<nc:LengthUnitCode>INH</nc:LengthUnitCode>
</nc:PersonHeightMeasure>Code: Select all
<nc:PersonHeightMeasure>
<nc:MeasureText>
<xsl:choose>
<xsl:when test="HeightFeet">
<xsl:value-of select="(HeightFeet*12) + HeightInches "/>
</xsl:when>
</xsl:choose>
</nc:MeasureText>
<nc:MeasureUnitText>
<xsl:text>inches</xsl:text>
</nc:MeasureUnitText>
<nc:LengthUnitCode>
<xsl:text>INH</xsl:text>
</nc:LengthUnitCode>
</nc:PersonHeightMeasure>
Re: How do I display HeightFeet element?
Hi,
It might depend also on the XSLT processor you are using. I tried to create a small 2.0 XSLT stylesheet with your code and run it with Saxon 9, the XSLT stylesheet I tested was like this:
and it seemed to work for me. I added in the XSLT one more choice to take into account that the HeightInches element might sometimes be missing from the XML document.
Regards,
Radu
It might depend also on the XSLT processor you are using. I tried to create a small 2.0 XSLT stylesheet with your code and run it with Saxon 9, the XSLT stylesheet I tested was like this:
Code: Select all
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0" xmlns:nc="gogo">
<xsl:output indent="yes"></xsl:output>
<xsl:template match="Party">
<nc:PersonHeightMeasure>
<nc:MeasureText>
<xsl:choose>
<xsl:when test="HeightFeet and HeightInches">
<xsl:variable name="feet" select="HeightFeet"/>
<xsl:variable name="inches" select="HeightInches"/>
<xsl:value-of select="$feet * 12 + $inches "/>
</xsl:when>
<xsl:when test="HeightFeet">
<xsl:variable name="feet" select="HeightFeet"/>
<xsl:value-of select="$feet * 12"/>
</xsl:when>
</xsl:choose>
</nc:MeasureText>
<nc:MeasureUnitText>
<xsl:text>inches</xsl:text>
</nc:MeasureUnitText>
<nc:LengthUnitCode>
<xsl:text>INH</xsl:text>
</nc:LengthUnitCode>
</nc:PersonHeightMeasure>
</xsl:template>
</xsl:stylesheet>
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
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