Modify value of an Attribute using XSLT

Here should go questions about transforming XML with XSLT and FOP.
roxyrollers
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="2.6.0.23" graphType="LINE_VERT_ABS">

<xsl:stylesheet version="1.0" 
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output omit-xml-declaration="yes" indent="yes"/>
    <xsl:param name="pNewMarkerShape" select="'MS_CIRCLE'"/>

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

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

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

</Graph>

-->
</rw:graph>

Radu
Posts: 7422
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

Hi,

Maybe you should start by finding tutorials to learn XSLT. We have this past webinar for example:
https://www.youtube.com/watch?v=-Ssc4dXRPto

There is also this Udemy course with a number of free lessons:
https://www.udemy.com/course/practical- ... 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.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Post Reply