Commit 712c67f9 authored by Jérôme Euzenat's avatar Jérôme Euzenat
Browse files

- corrected errors in both rule files

- updated copyright statements
parent a051d2fa
/*
* $Id: Ruleset.java,v 1.5 2003-01-30 15:47:46 triolet Exp $
* $Id: Ruleset.java,v 1.6 2004-02-24 13:53:19 jerome Exp $
*
* Transmorpher
*
......@@ -91,23 +91,23 @@ public class Ruleset extends TransformationImpl implements Namespaced {
*@param index index in the list
*/
public void insertRule(Rule rule, int index) {
rules.add(index, (Object)rule);
rules.add(index, (Object)rule);
}
/**
* Prints the XML expression of the process
*/
public void generateXML() {
System.out.println(" <ruleset name=\"" + name + "\" type=\"" + type + "\">");
for (int i = 0; i < namespaces.size(); i++) {
((Namespace)namespaces.get(i)).generateXML();
}
parameters.generateXMLDeclarations();
for (int i = 0; i < rules.size(); i++) {
((Rule)rules.get(i)).generateXML();
}
System.out.println(" </ruleset>");
System.out.println();
System.out.println(" <ruleset name=\"" + name + "\" type=\"" + type + "\">");
for (int i = 0; i < namespaces.size(); i++) {
((Namespace)namespaces.get(i)).generateXML();
}
parameters.generateXMLDeclarations();
for (int i = 0; i < rules.size(); i++) {
((Rule)rules.get(i)).generateXML();
}
System.out.println(" </ruleset>");
System.out.println();
}
/**
......@@ -126,18 +126,18 @@ public class Ruleset extends TransformationImpl implements Namespaced {
*@exception IOException Description of the Exception
*/
public void generateXSLTStylesheet(String reloc) throws TMException, IOException {
String vPath = getTransmorpher().getFile().getAbsoluteFile().getParent();
if (vPath == null) {
vPath = ".";
} else {
vPath = vPath.replace('\\', '/');
}
if (reloc != null) {
vPath = reloc;
}
//System.out.println("[RuleSEt] vPath = " + vPath +" Reloc = "+ reloc);
generateXSLTCode(new Writer(vPath + "/" + name + ".xsl"));
attributes.setParameter("file", vPath + "/" + name + ".xsl");
String vPath = getTransmorpher().getFile().getAbsoluteFile().getParent();
if (vPath == null) {
vPath = ".";
} else {
vPath = vPath.replace('\\', '/');
}
if (reloc != null) {
vPath = reloc;
}
//System.out.println("[RuleSEt] vPath = " + vPath +" Reloc = "+ reloc);
generateXSLTCode(new Writer(vPath + "/" + name + ".xsl"));
attributes.setParameter("file", vPath + "/" + name + ".xsl");
}
/**
......@@ -148,49 +148,49 @@ public class Ruleset extends TransformationImpl implements Namespaced {
*@exception IOException Description of the Exception
*/
public void generateXSLTCode(Writer file) throws TMException, IOException {
file.writeln("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
file.writeln("<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\"");
for (int i = 0; i < namespaces.size(); i++) {
((Namespace)namespaces.get(i)).generateXSLTCode(file);
}
file.writeln(" xmlns:regexp=\"http://fr.fluxmedia.transmorpher.stdlib.RegularExpression\">");
file.writeln("");
file.writeln("<!-- ************************************************************");
file.writeln(" Generated by " + Version.NAME + " " + Version.RELEASE);
Date date = new Date();
file.writeln(" " + date);
file.writeln(" See " + Version.URL);
file.writeln(" ************************************************************ -->");
for (Enumeration e = parameters.getNames(); e.hasMoreElements(); ) {
String key = (String)e.nextElement();
file.writeln(2, "<xsl:param name=\"" + key + "\">" + parameters.getParameter(key) + "</xsl:param>");
}
file.writeln("");
file.writeln(" <!-- Copying the root and its attributes -->");
file.writeln(" <xsl:template match=\"/\">");
file.writeln(" <xsl:apply-templates/>");
file.writeln(" </xsl:template>");
file.writeln(" <xsl:template match=\"@*\">");
file.writeln(" <xsl:attribute name=\"{name()}\"><xsl:value-of select=\".\"/>");
file.writeln(" </xsl:attribute>");
file.writeln(" </xsl:template>");
file.writeln("");
file.writeln(" <!-- Copying all elements and attributes -->");
file.writeln(" <xsl:template match=\"*\">");
file.writeln(" <xsl:copy>");
file.writeln(" <xsl:apply-templates select=\"*|@*|text()\"/>");
file.writeln(" </xsl:copy>");
file.writeln(" </xsl:template>");
file.writeln("");
file.writeln("<!-- ************************************************************ -->");
file.writeln("<!-- End of the general section, here begins the stylesheet -->");
file.writeln("<!-- ************************************************************ -->");
file.writeln("");
for (int i = 0; i < rules.size(); i++) {
((Rule)rules.get(i)).generateXSLTCode(file);
}//end for
file.writeln("</xsl:stylesheet>");
file.close();
file.writeln("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
file.writeln("<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\"");
for (int i = 0; i < namespaces.size(); i++) {
((Namespace)namespaces.get(i)).generateXSLTCode(file);
}
file.writeln(" xmlns:regexp=\"http://fr.fluxmedia.transmorpher.stdlib.RegularExpression\">");
file.writeln("");
file.writeln("<!-- ************************************************************");
file.writeln(" Generated by " + Version.NAME + " " + Version.RELEASE);
Date date = new Date();
file.writeln(" " + date);
file.writeln(" See " + Version.URL);
file.writeln(" ************************************************************ -->");
for (Enumeration e = parameters.getNames(); e.hasMoreElements(); ) {
String key = (String)e.nextElement();
file.writeln(2, "<xsl:param name=\"" + key + "\">" + parameters.getParameter(key) + "</xsl:param>");
}
file.writeln("");
file.writeln(" <!-- Copying the root and its attributes -->");
file.writeln(" <xsl:template match=\"/\">");
file.writeln(" <xsl:apply-templates/>");
file.writeln(" </xsl:template>");
file.writeln(" <xsl:template match=\"@*\">");
file.writeln(" <xsl:attribute name=\"{name()}\"><xsl:value-of select=\".\"/>");
file.writeln(" </xsl:attribute>");
file.writeln(" </xsl:template>");
file.writeln("");
file.writeln(" <!-- Copying all elements and attributes -->");
file.writeln(" <xsl:template match=\"*\">");
file.writeln(" <xsl:copy>");
file.writeln(" <xsl:apply-templates select=\"*|@*|text()\"/>");
file.writeln(" </xsl:copy>");
file.writeln(" </xsl:template>");
file.writeln("");
file.writeln("<!-- ************************************************************ -->");
file.writeln("<!-- End of the general section, here begins the stylesheet -->");
file.writeln("<!-- ************************************************************ -->");
file.writeln("");
for (int i = 0; i < rules.size(); i++) {
((Rule)rules.get(i)).generateXSLTCode(file);
}//end for
file.writeln("</xsl:stylesheet>");
file.close();
}
}
......
/**
* $Id: Flatten.java,v 1.2 2003-01-16 13:37:41 triolet Exp $
* $Id: Flatten.java,v 1.3 2004-02-24 13:53:19 jerome Exp $
*
* Transmorpher
*
* Copyright (C) 2001-2002 Fluxmedia and INRIA Rhne-Alpes.
* Copyright (C) 2004 INRIA Rhne-Alpes.
*
* http://www.fluxmedia.fr - http://transmorpher.inrialpes.fr
*
......@@ -105,7 +106,7 @@ public class Flatten implements Rule {
file.writeln(2, "<!-- Flatten for " + match + " (default mode) -->");
file.writeln(2, "<xsl:template match=\"" + match + "\">");
file.writeln(4, "<xsl:copy>");
file.writeln(6, "<xsl:apply-templates select=\"./*|./text()\" mode=\"inside" + match + "\">");
file.writeln(6, "<xsl:apply-templates select=\"./*|./text()\" mode=\"inside" + match + "\"/>");
file.writeln(4, "</xsl:copy>");
file.writeln(2, "</xsl:template>");
file.writeln("");
......@@ -118,14 +119,16 @@ public class Flatten implements Rule {
file.writeln(2, "<!-- Flatten for " + match + " (inside mode) -->");
file.writeln(2, "<xsl:template match=\"" + match + "\" mode=\"inside" + match + "\">");
file.writeln(4, "<xsl:copy>");
file.writeln(6, "<xsl:apply-templates select=\"./*|./text()\" mode=\"inside" + match + "\">");
file.writeln(4, "</xsl:copy>");
file.writeln(4, "<xsl:for-each select=\"*|text()\">");
file.writeln(6, "<xsl:copy>");
file.writeln(8, "<xsl:apply-templates mode=\"inside" + match + "\"/>");
file.writeln(6, "</xsl:copy>");
file.writeln(4, "</xsl:for-each>");
file.writeln(2, "</xsl:template>");
file.writeln("");
file.writeln(2, "<xsl:template match=\"*|@*|text()\" mode=\"inside" + match + "\">");
file.writeln(4, "<xsl:copy>");
file.writeln(6, "<xsl:apply-templates select=\"*|text()\">");
file.writeln(6, "<xsl:apply-templates select=\"*|@*|text()\"/>");
file.writeln(4, "</xsl:copy>");
file.writeln(2, "</xsl:template>");
file.writeln("");
......
/**
* $Id: MapAtt.java,v 1.2 2003-01-16 13:37:41 triolet Exp $
* $Id: MapAtt.java,v 1.3 2004-02-24 13:53:19 jerome Exp $
*
* Transmorpher
*
* Copyright (C) 2001-2002 Fluxmedia and INRIA Rhône-Alpes.
* Copyright (C) 2004 INRIA Rhône-Alpes.
*
* http://www.fluxmedia.fr - http://transmorpher.inrialpes.fr
*
......@@ -186,7 +187,7 @@ public class MapAtt implements Rule {
public void generateInsideXSLTCode(Writer file) throws IOException {
file.writeln(6, "<!-- Mapping attributes " + match + " to " + target + " -->");
file.writeln(6, "<xsl:attribute name=\"" + target + "\">");
file.write("<xsl:value-of select=\"@" + match + "\"/>");
file.write("<xsl:value-of select=\".\"/>");
file.writeln(6, "</xsl:attribute>");
file.writeln("");
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment