Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Find fonctionnel

transform à priori fonctionnel
copy d'un xmlElement fonctionnel
  • Loading branch information...
commit 67f0f98e1a04a77cba7679b8cd5a8d18773752ca 1 parent 40804e3
@RDeville RDeville authored
View
BIN  analyseur/analyse
Binary file not shown
View
4 analyseur/analyse.cpp
@@ -78,10 +78,8 @@ int main(int argc, char **argv)
xmlTree->display();
printf("======================================================\n");
- xslTree->display();
- xmlTree->getChildElement(0)->display();
find(xmlTree->getChildElement(0),xslTree);
-
+ xslTree->display();
return 0;
}
View
BIN  analyseur/analyse.dSYM/Contents/Resources/DWARF/analyse
Binary file not shown
View
6 analyseur/rap1.xsl
@@ -3,7 +3,7 @@
<xsl:template match="rapport">
<html>
<head>
- <title>Title: <xsl:value-of select="//titre"/></title>
+ <title>Title: TP Analyseur XML</title>
</head>
<body>
<xsl:apply-templates/>
@@ -34,10 +34,6 @@
<xsl:apply-templates/>
</xsl:template>
-<xsl:template match="titre">
- <h4><xsl:apply-templates/></h4>
-</xsl:template>
-
<xsl:template match="section">
<xsl:apply-templates/>
</xsl:template>
View
50 analyseur/xmlElement.cpp
@@ -1,4 +1,5 @@
#include "xmlElement.h"
+#include "xmlText.h"
#include <list>
#include <typeinfo>
#include <iostream>
@@ -65,6 +66,11 @@ vector<xmlNode*> xmlElement::getAllChildNode()
{
return childNode;
}
+
+vector<xmlNode*> * xmlElement::getAllChildNodeVector()
+{
+ return &childNode;
+}
xmlNode* xmlElement::getChildNode(int i)
{
@@ -76,6 +82,11 @@ vector<xmlElement*> xmlElement::getAllChildElement()
return childElement;
}
+vector<xmlElement*> * xmlElement::getAllChildElementVector()
+{
+ return &childElement;
+}
+
xmlElement* xmlElement::getChildElement(int i)
{
return childElement[i];
@@ -137,7 +148,8 @@ xmlElement * xmlElement::getElementByFullName(string elName)
}
else
{
- xmlElement* result = childElement[i]->getElementByFullName(name);
+ xmlElement* result = childElement[i]->getElementByFullName(elName);
+ cout << "==============\n\n=========" << childElement[i]->getFullName() << endl;
if (result != NULL)
return result;
}
@@ -145,6 +157,42 @@ xmlElement * xmlElement::getElementByFullName(string elName)
return NULL;
}
+
+xmlElement * xmlElement::copy ()
+{
+ cout << "XML ELEMENT COPY 1!!!" << endl;
+ xmlElement * newEltResult;
+ cout << name << endl;
+ if (ns == "")
+ newEltResult = new xmlElement(name);
+ else
+ newEltResult = new xmlElement(name,ns);
+ cout << "XML ELEMENT COPY 2!!" << endl;
+ for (int i = 0 ; i < childNode.size() ; i++)
+ {
+ cout << "XML ELEMENT COPY 3!!" << endl;
+ xmlNode * tempChild = childNode[i];
+ xmlElement * tempElement = dynamic_cast<xmlElement*>(tempChild);
+ cout << "XML ELEMENT COPY 4!!" << endl;
+ if(tempElement != NULL)
+ {
+ cout << "XML ELEMENT COPY 5!!" << endl;
+ newEltResult->addXmlNode(tempElement->copy());
+ }
+ else
+ {
+ cout << "XML ELEMENT COPY 6!!" << endl;
+ xmlText * tempText = new xmlText(((xmlText*)tempChild)->getText());
+ newEltResult->addXmlNode(tempText);
+ }
+ }
+ cout << "XML ELEMENT COPY !!!" << endl;
+ newEltResult->display();
+ cout << "END XML ELEMENT COPY !!!" << endl;
+ return newEltResult;
+}
+
+
void xmlElement::display()
{
if (ns=="")
View
3  analyseur/xmlElement.h
@@ -36,8 +36,10 @@ class xmlElement : public xmlNode {
int getAttributeCount();
int getChildElementCount();
vector<xmlNode*> getAllChildNode();
+ vector<xmlNode*> * getAllChildNodeVector();
xmlNode* getChildNode(int i);
vector<xmlElement*> getAllChildElement();
+ vector<xmlElement*> * getAllChildElementVector();
xmlElement * getChildElement(int i);
xmlElement * getParent();
@@ -47,6 +49,7 @@ class xmlElement : public xmlNode {
void addXmlNode(xmlNode * elNode);
xmlElement * getElementByName(string name);
xmlElement * getElementByFullName(string elName);
+ xmlElement * copy ();
void display();
};
View
1  analyseur/xmlNode.cpp
@@ -13,3 +13,4 @@ xmlNode::~xmlNode()
void xmlNode::display()
{
}
+
View
1  analyseur/xmlText.cpp
@@ -20,6 +20,7 @@ string xmlText::getText()
return text;
}
+
void xmlText::display()
{
cout << text << endl;
View
54 analyseur/xmlTransform.cpp
@@ -17,22 +17,18 @@ void find (xmlElement* elNode, xmlElement* xslRoot)
for (int j = 0 ; j < attCount ; j++)
{
currentAtt = elCurrent->getAttribute(j);
- cout << (currentAtt->id == "match") << "=" << (currentAtt->value == elNode->getName()) << endl;
if ((currentAtt->id == "match") && (currentAtt->value == elNode->getName()))
{
- //transform(elNode,elCurrent);
- xmlElement* temp = elCurrent;
+ elCurrent->display();
+ xmlElement* elApplyTemplates = elCurrent->getElementByFullName("xsl:apply-templates");
xmlElement* elNodeParent = elNode->getParent();
int i = 0;
- if (elNodeParent != NULL)
+ if (elApplyTemplates!= NULL)
{
- temp = temp->getElementByFullName("xsl:apply-templates");
- if (temp != NULL)
- cout << "Apply-Temlates find for : " << temp->getName() << endl;
- else
- cout << "Apply-Temlates not find for : " << endl; // << temp->getName() << endl;
- }
- find = true;
+ transform(elNode,elCurrent,elApplyTemplates );
+ find = true;
+ break;
+ }
}
}
}
@@ -40,13 +36,37 @@ void find (xmlElement* elNode, xmlElement* xslRoot)
}
}
-void transform (xmlElement*& elNode, xmlElement* elNewParent)
+
+void transform (xmlElement*& elXMLNode, xmlElement * elXSLTemplate , xmlElement* elApplyTemplates)
{
- xmlElement* temp = elNewParent;
- xmlElement* elNodeParent = elNode->getParent();
- int i = 0;
- if (elNodeParent != NULL)
+ int itNode = 0;
+ int itElement = 0;
+ bool find = false;
+
+ elXMLNode->setParent(elApplyTemplates->getParent());
+ xmlElement * elATParent = elApplyTemplates->getParent(); //elATParent = elApplyTemplatesParent
+
+ while (find == false && itNode < elATParent->getAllChildNode().size())
{
+ if (elATParent->getChildNode(itNode) == elApplyTemplates)
+ {
+ elATParent->getAllChildNodeVector()->at(itNode) = elXMLNode;
+ find = true;
+ }
+ else
+ itNode++;
}
-
+ find = false;
+ while (find == false && itElement < elATParent->getAllChildElement().size())
+ {
+ if (elATParent->getChildElement(itElement) == elApplyTemplates)
+ {
+ elATParent->getAllChildElementVector()->at(itElement) = elXMLNode;
+ find = true;
+ }
+ else
+ itElement++;
+ }
+ xmlElement * test = elXSLTemplate->copy();
}
+
View
2  analyseur/xmlTransform.h
@@ -9,6 +9,6 @@ using namespace std;
void find(xmlElement* elNode, xmlElement* xslRoot);
-void tranform(xmlElement* &elNode, xmlElement* elNewParent);
+void transform (xmlElement*& elXMLNode, xmlElement * elXSLTemplate , xmlElement* elApplyTemplates);
#endif
Please sign in to comment.
Something went wrong with that request. Please try again.