Bug 47604

Summary: [PATCH] Implementation of an XML to XLSX Importer using Custom XML Mapping
Product: POI Reporter: Roberto Manicardi <roberto.manicardi>
Component: XSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 3.5-dev   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X 10.4   
Attachments: The diff file
New files
Added this issue in status.xml file

Description Roberto Manicardi 2009-07-29 14:00:03 UTC
Created attachment 24061 [details]
The diff file

I've implemented a tool to import XML files into XLSX using the Custom XML Mapping defined in the XLSX.


This closes the loop I've started with the XML exporter (https://issues.apache.org/bugzilla/show_bug.cgi?id=47520).

I've added some use cases in the test file 
- src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFImportFromXML.java

To give a quick snippet of code on how to use the importer
    // gets one of the Custom XML mapping configured in the workbook
    XSSFMap map = workbook.getMapInfo().getXSSFMapByName("mapping name");
    // creates a new importer for the mapping
    XSSFImportFromXML importer = new XSSFImportFromXML(map);
    // imports the XML
    importer.importFromXML(testXML);



I did also some little modifications to enable an easier access to the map info data:

  - XSSFMapInfo : added the new method getXSSFMapByName(String mapName)
  - XSSFWorkbook: added a new method to retreive the XSSFMapInfo object
  - XSSFSingleXmlCell: if the related XSSFCell doesn't exists, create a new one when tring to retreive it
  - XSSFXmlColumnPr : added new getId() and getXPath() methods
Comment 1 Roberto Manicardi 2009-07-29 14:02:23 UTC
Created attachment 24062 [details]
New files

Added the following files
-XSSFImportFromXML.java: Importer
-TestXSSFImportFromXML.java: Junit test
-CustomXMLMapping-singleattributenamespace.xlsx : used for testing purpose
Comment 2 Paolo Mottadelli 2009-07-30 06:25:29 UTC
Patch applied. Thanks
Comment 3 Roberto Manicardi 2009-07-31 05:25:53 UTC
Created attachment 24071 [details]
Added this issue in status.xml file
Comment 4 Roberto Manicardi 2009-07-31 05:27:11 UTC
I've forgot to set this issue in the status.xml file. I've attached a new patch, could you plese add it to the trunk?

Thanks,
Roberto
Comment 5 Yegor Kozlov 2009-08-05 11:00:31 UTC
Added in r801342

Yegor