00001
00002
00003
00004
00005
00006
00007
00008
00015 #include <zypp/parser/yum/YUMOtherParser.h>
00016 #include <istream>
00017 #include <string>
00018 #include "zypp/parser/xml_parser_assert.h"
00019 #include <libxml/xmlstring.h>
00020 #include <libxml/xmlreader.h>
00021 #include <libxml/tree.h>
00022 #include <zypp/parser/LibXMLHelper.h>
00023 #include <zypp/base/Logger.h>
00024 #include <zypp/parser/yum/schemanames.h>
00025 #include <zypp/ZYppFactory.h>
00026
00027 using namespace std;
00028 namespace zypp
00029 {
00030 namespace parser
00031 {
00032 namespace yum
00033 {
00034
00035
00036 YUMOtherParser::YUMOtherParser(std::istream &is, const std::string& baseUrl, parser::ParserProgress::Ptr progress )
00037 : XMLNodeIterator<YUMOtherData_Ptr>(is, baseUrl,OTHERSCHEMA, progress)
00038 , _zypp_architecture( getZYpp()->architecture() )
00039 {
00040 fetchNext();
00041 }
00042
00043 YUMOtherParser::YUMOtherParser()
00044 : _zypp_architecture( getZYpp()->architecture() )
00045 { }
00046
00047 YUMOtherParser::YUMOtherParser(YUMOtherData_Ptr& entry)
00048 : XMLNodeIterator<YUMOtherData_Ptr>(entry)
00049 , _zypp_architecture( getZYpp()->architecture() )
00050 { }
00051
00052
00053
00054 YUMOtherParser::~YUMOtherParser()
00055 {}
00056
00057
00058
00059
00060
00061 bool
00062 YUMOtherParser::isInterested(const xmlNodePtr nodePtr)
00063 {
00064 bool result = (_helper.isElement(nodePtr)
00065 && _helper.name(nodePtr) == "package");
00066 return result;
00067 }
00068
00069
00070
00071 YUMOtherData_Ptr
00072 YUMOtherParser::process(const xmlTextReaderPtr reader)
00073 {
00074 xml_assert(reader);
00075 YUMOtherData_Ptr dataPtr = new YUMOtherData;
00076 xmlNodePtr dataNode = xmlTextReaderExpand(reader);
00077 xml_assert(dataNode);
00078
00079 dataPtr->pkgId = _helper.attribute(dataNode,"pkgid");
00080 dataPtr->name = _helper.attribute(dataNode,"name");
00081 dataPtr->arch = _helper.attribute(dataNode,"arch");
00082
00083 try
00084 {
00085 if (!Arch(dataPtr->arch).compatibleWith( _zypp_architecture ))
00086 {
00087 return NULL;
00088 }
00089 }
00090 catch ( const Exception & excpt_r )
00091 {
00092 ZYPP_CAUGHT( excpt_r );
00093 DBG << "Skipping malformed " << dataPtr->arch << endl;
00094 return NULL;
00095 }
00096
00097 for (xmlNodePtr child = dataNode->children;
00098 child != 0;
00099 child = child->next)
00100 {
00101 if (_helper.isElement(child))
00102 {
00103 string name = _helper.name(child);
00104 if (name == "version")
00105 {
00106 dataPtr->epoch = _helper.attribute(child,"epoch");
00107 dataPtr->ver = _helper.attribute(child,"ver");
00108 dataPtr->rel = _helper.attribute(child,"rel");
00109 }
00110 else if (name == "changelog")
00111 {
00112 #if 0
00113 dataPtr->changelog.push_back
00114 (ChangelogEntry(_helper.attribute(child,"author"),
00115 _helper.attribute(child,"date"),
00116 _helper.content(child)));
00117 #endif
00118 }
00119 else
00120 {
00121 WAR << "YUM <otherdata> contains the unknown element <" << name << "> "
00122 << _helper.positionInfo(child) << ", skipping" << endl;
00123 }
00124 }
00125 }
00126 return dataPtr;
00127 }
00128
00129 }
00130 }
00131 }