001/**************************************************************************** 002 * Copyright/Copyleft: 003 * 004 * For this source the LGPL Lesser General Public License, 005 * published by the Free Software Foundation is valid. 006 * It means: 007 * 1) You can use this source without any restriction for any desired purpose. 008 * 2) You can redistribute copies of this source to everybody. 009 * 3) Every user of this source, also the user of redistribute copies 010 * with or without payment, must accept this license for further using. 011 * 4) But the LPGL ist not appropriate for a whole software product, 012 * if this source is only a part of them. It means, the user 013 * must publish this part of source, 014 * but don't need to publish the whole source of the own product. 015 * 5) You can study and modify (improve) this source 016 * for own using or for redistribution, but you have to license the 017 * modified sources likewise under this LGPL Lesser General Public License. 018 * You mustn't delete this Copyright/Copyleft inscription in this source file. 019 * 020 * @author www.vishia.de/Java 021 * @version 2006-06-15 (year-month-day) 022 * list of changes: 023 * 2006-05-00 JcHartmut: creation 024 * 025 ****************************************************************************/ 026package org.vishia.xml; 027 028import net.sf.saxon.om.Axis; 029import net.sf.saxon.om.AxisIterator; 030import net.sf.saxon.om.Item; 031import net.sf.saxon.om.NodeInfo; 032import net.sf.saxon.type.Type; 033 034 035/**Not ready yet, it is a trying to use the saxons path */ 036public class WikiFormat 037{ 038 void process(NodeInfo xmlTree) 039 { processNodeAndChilds(xmlTree); 040 041 042 AxisIterator iterChild = xmlTree.iterateAxis(Axis.CHILD); 043 Item itemChild = iterChild.current(); 044 @SuppressWarnings("unused") 045 NodeInfo child = (NodeInfo)(itemChild); 046 //processNodesAtLevel(child); 047 048 } 049 050 void processNodesAtLevel(NodeInfo node) 051 { 052 processNodeAndChilds(node); 053 AxisIterator iter; 054 iter = node.iterateAxis(Axis.FOLLOWING_SIBLING); 055 do 056 { 057 Item item = iter.current(); 058 if(item instanceof NodeInfo) 059 { node = (NodeInfo)(item); 060 processNodeAndChilds(node); 061 } 062 } while(iter.moveNext()); 063 064 } 065 066 067 void processNodeAndChilds(NodeInfo node) 068 { 069 int type = node.getNodeKind(); 070 switch(type) 071 { case Type.ELEMENT: 072 { 073 074 } break; 075 case Type.ATTRIBUTE: 076 { 077 078 } break; 079 080 } 081 String name = node.getDisplayName(); 082 String value = node.getStringValue(); 083 System.out.println(name + ":" + value); 084 AxisIterator iterChild = node.iterateAxis(Axis.CHILD); 085 Item itemChild = iterChild.current(); 086 if(itemChild instanceof NodeInfo) 087 { NodeInfo child = (NodeInfo)(itemChild); 088 processNodesAtLevel(child); 089 } 090 091 } 092 093}