Modify value of an Attribute using XSLT

Here should go questions about transforming XML with XSLT and FOP.
Posts: 1
Joined: Fri Dec 11, 2020 3:28 am

Modify value of an Attribute using XSLT

Post by roxyrollers » Fri Dec 11, 2020 3:33 am

I am generating a Graph from Oracle Reports which is working well as far as plotting the points. However, I have hit a brick wall while working with XSLT (Complete novice here in the field). The Attribute markerShape is used to plot the different symbols in the Graph. However, because my Data is dynamic, I have to achieve this using XSLT.

What I am trying to achieve: I have a column called category which is based on a Query in Oracle Reports. The rules are as follows:
  • When category = 1 then markerShape = 'MS_CIRCLE'
    When category = 2 then markerShape = 'MS_DIAMOND'
    When category = 3 then markerShape = 'MS_SQUARE'
    When category = 4 then markerShape = 'MS_PLUS'
My XML which is only attempting to assign a value to an Attribute as this stage. I have not figured out how to read the value in category.

Code: Select all

<rw:graph id="CT_1" src="G_category" groups="x_date" dataValues="category">
<?xml version="1.0" ?>

<Graph version="" graphType="LINE_VERT_ABS">

<xsl:stylesheet version="1.0" 
    <xsl:output omit-xml-declaration="yes" indent="yes"/>
    <xsl:param name="pNewMarkerShape" select="'MS_CIRCLE'"/>

    <xsl:template match="node()|@*">
            <xsl:apply-templates select="node()|@*"/>

    <xsl:template match="SeriesItems/Series/@markerShape">
        <xsl:attribute name="markerShape">
            <xsl:value-of select="$pNewMarkerShape"/>

<Series id="0" markerShape="MS_NONE" lineWidth="1" color="#FFFFFF"/>



Posts: 7434
Joined: Fri Jul 09, 2004 5:18 pm

Re: Modify value of an Attribute using XSLT

Post by Radu » Mon Dec 14, 2020 1:58 pm


Maybe you should start by finding tutorials to learn XSLT. We have this past webinar for example:

There is also this Udemy course with a number of free lessons: ... and-xpath/

Other than that it is not quite clear to me what you want, maybe you can post a small XML sample and a small XSLT and give more details because right now you seem to have an XML document with XSLT inside it which does not make sense.

Radu Coravu
<oXygen/> XML Editor

Post Reply