# # You should have received a copy of the GNU General Public License # along with the srcML Toolkit; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # RelaxNG usage. import srcml if __name__ == "__main__": iarchive = srcml.create_archive() oarchive = None srcml.read_open_filename(iarchive, "project.xml") oarchive = srcml.clone_archive(iarchive) srcml.write_open_filename(oarchive, "relaxng.xml") srcml.append_transform_relaxng_filename(iarchive, "schema.rng"); srcml.apply_transforms(iarchive, oarchive); srcml.close_archive(iarchive); srcml.close_archive(oarchive); srcml.free_archive(iarchive); srcml.free_archive(oarchive);
if __name__ == "__main__": iarchive = None includearchive = None otherarchive = None unit = None # open up an existing archive iarchive = srcml.create_archive() srcml.read_open_filename(iarchive, "project.xml") # create a new srcml archive structure # options and attributes of cloned archive start the same as # the original archive includearchive = srcml.clone_archive(iarchive) otherarchive = srcml.clone_archive(iarchive) # open a srcML archive for output srcml.write_open_filename(includearchive, "project_include.xml") srcml.write_open_filename(otherarchive, "project_other.xml") # copy the files from the input archive to the output archive unit = srcml.read_unit(iarchive) while unit != None: # Get the filename filename = srcml.unit_get_filename(unit) if cmp(".h", filename[len(filename) - 2:]) == 0: srcml.write_unit(includearchive, unit) else: srcml.write_unit(otherarchive, unit)