Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 19th, 2006, 05:57 AM
Authorized User
Join Date: Apr 2006
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help with this code

Hi, I'm trying to transform a PMML file to Graphml, but I've had some problems.

In the PMML file there are several child elements, but the one I want to work with is: AssociationModel and their children.

<?xml version="1.0" encoding="UTF-8"?>
<PMML version="3.0" xmlns="http://www.dmg.org/PMML-3_0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Header copyright="Copyright (c) Integral Solutions Ltd., 1994 - 2005. All rights reserved.">
<DataDictionary numberOfFields="2">
<DataField name="cardid" optype="continuous" dataType="integer">
<Extension name="storageType" value="numeric"/>
<DataField name="Product" optype="categorical" dataType="string">
<Extension name="storageType" value="string"/>
<Value value="beer" property="valid"/>
<Value value="cannedmeat" property="valid"/>
<Value value="cannedveg" property="valid"/>
<Value value="confectionery" property="valid"/>
<Value value="dairy" property="valid"/>
<Value value="fish" property="valid"/>
<Value value="freshmeat" property="valid"/>
<Value value="frozenmeal" property="valid"/>
<Value value="fruitveg" property="valid"/>
<Value value="softdrink" property="valid"/>
<Value value="wine" property="valid"/>
<AssociationModel modelName="SHOPPING_ASSOC" algorithmName="Carma" functionName="associationRules" numberOfTransactions="939" minimumSupport="0.177848775292865" minimumConfidence="0.32013201320132" numberOfItems="7" numberOfItemsets="10" numberOfRules="18">
<MiningField name="cardid" usageType="group"/>
<MiningField name="Product" usageType="active"/>
<Item id="5" value="wine"/>
<Item id="7" value="fruitveg"/>
<Item id="4" value="confectionery"/>
<Item id="3" value="frozenmeal"/>
<Item id="6" value="fish"/>
<Item id="2" value="cannedveg"/>
<Item id="1" value="beer"/>
<Itemset id="9" numberOfItems="1" support="0.31096912">
<ItemRef itemRef="6"/>
<AssociationRule id="1" support="0.15548456" confidence="0.874251497005988" antecedent="1" consequent="2" lift="2.718285283737161"/>

The next code is the stylesheet and the problem is that I can't get the xslt processor reads the AssociationModel only and then with the template process the child elements. Any suggestion? Thanks in advance.

?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

    <xsl:output method="xml"/>

    <xsl:template match="/">
        <xsl:comment>This GraphML was generated from a PMML</xsl:comment>
        <graphml xmlns="http://graphml.graphdrawing.org/xmlns">
            <graph edgedefault="undirected">
                <xsl:apply-templates select="AssociationModel"/>

    <xsl:template match="PMML">
        <xsl:comment>read pmml tag</xsl:comment>
             <xsl:apply-templates select="AssociationModel"/>

    <xsl:template match="AssociationModel">
        <xsl:comment>read association_model tag</xsl:comment>

    <xsl:template match="Item">
       <xsl:element name="node">
                <xsl:attribute name="id">
                    <xsl:comment>read Item tag</xsl:comment>
                    <xsl:value-of select="id"/>

    <xsl:template match="Itemset">

    <xsl:template match="AssociationRule">


Reply With Quote
  #2 (permalink)  
Old April 19th, 2006, 06:28 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts

especially numbers 13 and 23.


Joe (Microsoft MVP - XML)
Reply With Quote
  #3 (permalink)  
Old April 19th, 2006, 07:11 AM
mhkay's Avatar
Wrox Author
Points: 18,481, Level: 59
Points: 18,481, Level: 59 Points: 18,481, Level: 59 Points: 18,481, Level: 59
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,960
Thanks: 0
Thanked 292 Times in 287 Posts

Your source document is in a namespace:

<PMML version="3.0" xmlns="http://www.dmg.org/PMML-3_0"

so you need to qualify all names with a prefix:


<xsl:template match="pmml:PMML">

In XSLT 2.0 you can say xpath-default-namespace="http://www.dmg.org/PMML-3_0"

on the xsl:stylesheet element (or elsewhere)

Michael Kay
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #4 (permalink)  
Old April 20th, 2006, 09:31 AM
Authorized User
Join Date: Apr 2006
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts

Thanks for the advice Joefawcett ;)

Reply With Quote
  #5 (permalink)  
Old April 20th, 2006, 09:32 AM
Authorized User
Join Date: Apr 2006
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts

It works now, thanks mhkay!

Reply With Quote
  #6 (permalink)  
Old December 6th, 2006, 07:20 PM
Registered User
Join Date: Dec 2006
Location: Sydney, , Australia.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts


If you're interested I've done a little fun work with PMML. Mostly as a means to learn a bit of VB.Net and test PMML exported by SPSS Clementine. Some of it include using XSLT to parse association models and convert into HTML. See the links below.

KDKeys Data Mining with Clementine;

SourceForge PMML homepage;


Reply With Quote
  #7 (permalink)  
Old May 27th, 2007, 02:48 AM
Registered User
Join Date: May 2007
Location: habana, habana, Cuba.
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts

HI, I need to transform a PMML file to SVG format but I´dont know how, please help me.....

<?xml version="1.0" ?>
  <PMML version="3.1" xmlns="http://www.dmg.org/PMML-3_1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Header copyright="dmg.org"/>
    <DataDictionary numberOfFields="3">
      <DataField name="marital status" optype="categorical" dataType="string">
          <Value value="s"/>
          <Value value="d"/>
          <Value value="m"/>
      <DataField name="age" optype="continuous" dataType="double"/>
      <DataField name="salary" optype="continuous" dataType="double"/>
    <ClusteringModel modelName="Mini Clustering"
               <MiningField name="marital status"/>
               <MiningField name="age"/>
               <MiningField name="salary"/>

      <ComparisonMeasure kind="distance">

      <ClusteringField field="marital status"
      <ClusteringField field="age"
      <ClusteringField field="salary"
        <DerivedField name="c1" optype="continuous" dataType="double">
          <NormContinuous field="age">
               <LinearNorm orig="45" norm="0"/>
               <LinearNorm orig="82" norm="0.5"/>
               <LinearNorm orig="105" norm="1"/>
        <DerivedField name="c2" optype="continuous" dataType="double">
          <NormContinuous field="salary">
               <LinearNorm orig="39000" norm="0"/>
               <LinearNorm orig="39800" norm="0.5"/>
               <LinearNorm orig="41000" norm="1"/>
        <DerivedField name="c3" optype="continuous" dataType="double">
          <NormDiscrete field="marital status" value="m"/>
        <DerivedField name="c4" optype="continuous" dataType="double">
          <NormDiscrete field="marital status" value="d"/>
        <DerivedField name="c5" optype="continuous" dataType="double">
          <NormDiscrete field="marital status" value="s"/>
        <Array n="5" type="real">1 1 1 1 1</Array>
      <Cluster name="marital status is d or s">
        <Array n="5" type="real">
               0.524561 0.486321 0.128427 0.459188 0.412384</Array>
      <Cluster name="marital status is m">
        <Array n="5" type="real">
               0.69946 0.419037 0.591226 0.173521 0.235253</Array>

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Urgent:hard disk serial code and vb code ivanlaw Pro VB 6 0 July 25th, 2007 04:05 AM
VB: .Exe file, serial code and activation code ivanlaw Pro VB 6 8 July 6th, 2007 05:44 AM
code clinic - Why wont example asp code work? jardbf Classic ASP Basics 3 April 27th, 2006 06:22 PM
Writing Client Side Script from Code-Behind code sajid_pk Classic ASP Databases 1 January 18th, 2005 12:53 AM
disable forum code within [code] blocks? nikolai Forum and Wrox.com Feedback 0 October 23rd, 2003 07:52 PM

All times are GMT -4. The time now is 05:34 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.