You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2009/07/08 07:59:08 UTC
DO NOT REPLY [Bug 47468] enable support to manage xs:any nodes with
XMLBeans
https://issues.apache.org/bugzilla/show_bug.cgi?id=47468
Yegor Kozlov <ye...@dinom.ru> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |INVALID
--- Comment #1 from Yegor Kozlov <ye...@dinom.ru> 2009-07-07 22:59:05 PST ---
Roberto,
There are two ways how you can access XML that does not have a getXXX()
accessor:
(1) Grab the DOM node and navigate using the DOM API:
Node node = xmlobject.getDomNode();
NodeList ch = node.getChildNodes();
...etc.
(2) Use built-in support for XPath. The XmlBeans API uses a dialect of XPath,
please consult http://xmlbeans.apache.org/ for further details.
Below is a sample code that reads xsd from the attached file:
XSSFWorkbook wb = new XSSFWorkbook("CustomXMLMappings.xlsx");
List<POIXMLDocumentPart> rel = wb.getRelations();
for(POIXMLDocumentPart p : rel){
if("http://schemas.openxmlformats.org/officeDocument/2006/relationships/xmlMaps".
equals(p.getPackageRelationship().getRelationshipType())){
InputStream is = p.getPackagePart().getInputStream();
CTSchema ct = CTSchema.Factory.parse(is);
//select XML tree for the schema
String query =
"declare namespace
w='http://schemas.openxmlformats.org/spreadsheetml/2006/main';" +
"$this/w:MapInfo/w:Schema";
XmlObject[] o = ct.selectPath(query);
for (XmlObject xsd : o){
XmlCursor cur = xsd.newCursor();
cur.selectPath("./*/*");
while (cur.toNextSelection()) {
XmlObject ch = cur.getObject();
System.out.println(ch);
}
}
}
}
Regards,
Yegor
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org