From: Paul T. <pt...@gm...> - 2006-11-16 13:07:57
|
thanks, jimmy. is there an example you might be able to point me to, that would do something like how you suggest? On 11/16/06, Jimmy Zhang <cra...@co...> wrote: > use while to looping thru all the tokens and collect those whose > types are character_data or cdata... and convert them to strings and > concatnate them... > ----- Original Message ----- > From: "Paul Tomsic" <pt...@gm...> > To: "Jimmy Zhang" <cra...@co...> > Cc: <vtd...@li...> > Sent: Wednesday, November 15, 2006 1:19 PM > Subject: Re: [Vtd-xml-users] mixed content? > > > > so how would i go about obtaining all of the contents of the "label" node? > > Suffix (the TEXT node) is a child of the "a" element which is a child > > of the "em" element, which is a child of "label" - unless i'm missing > > something (?) > > > > > > > > On 11/15/06, Jimmy Zhang <cra...@co...> wrote: > >> it seems to me that 'Suffix' is not a child of label ... > >> > >> ----- Original Message ----- > >> From: "Paul Tomsic" <pt...@gm...> > >> To: "Jimmy Zhang" <cra...@co...> > >> Cc: <vtd...@li...> > >> Sent: Wednesday, November 15, 2006 1:00 PM > >> Subject: Re: [Vtd-xml-users] mixed content? > >> > >> > >> > hi jimmy, thanks for the reply. perhaps i'm doing something incorrect, > >> > though. > >> > here's my xml snip: > >> > <customerModules> > >> > <name> > >> > <suffixField> > >> > <label> > >> > <![CDATA[foo && <>bar]]><em><a > >> > href="http://www.yahoo.com">Suffix</a></em> > >> > </label> > >> > </suffixField> > >> > </name> > >> > > >> > > >> > what'd i'd be expecting to get back is the entire contents of the > >> > name/suffixField/label node. > >> > > >> > here's my code: > >> > // _node here is a dom representation of "label" > >> > StringBuffer tmp = new StringBuffer(); > >> > try { > >> > // converts a w3c node to a byte[] > >> > b = DOMUtil.toByteArray(_node); > >> > vg.setDoc_BR(b); > >> > vg.parse(true); > >> > VTDNav vn = vg.getNav(); > >> > > >> > ap.bind(vn); > >> > TextIter ti = new TextIter(); > >> > ti.touch(vn); > >> > int i; > >> > while ((i = ti.getNext()) != -1) { > >> > tmp.append(vn.toString(i)); > >> > } > >> > > >> > the results i'm getting back (what's in the string buffer above) is: > >> > "foo && <>bar" > >> > it didn't seem to pick up the 'em' and the 'a href' contents > >> > > >> > thoughts? > >> > > >> > On 11/15/06, Jimmy Zhang <cra...@co...> wrote: > >> >> I have a quick correction... > >> >> > >> >> The basic syntax is as follows > >> >> > >> >> // assuming vn is an instance of VTDNav > >> >> ti = new textIter(); // textIterator instantiation > >> >> ti.touch(vn); // bind the cursor to the cursor element > >> >> while( (int i= ti.getNext())!= -1){ > >> >> // i is the text node associated with the element at the cursor > >> >> //position > >> >> system.out.println("text node is ==> "+vn.toString(i)); > >> >> } > >> >> > >> >> > >> >> ----- Original Message ----- > >> >> From: "Jimmy Zhang" <cra...@co...> > >> >> To: "Paul Tomsic" <pt...@gm...>; > >> >> <vtd...@li...> > >> >> Sent: Wednesday, November 15, 2006 10:34 AM > >> >> Subject: Re: [Vtd-xml-users] mixed content? > >> >> > >> >> > >> >> > Yes, it is possible, there is a little mentioned class called > >> >> > textIterator > >> >> > that you can use for that purpose.. > >> >> > > >> >> > if there are more than one child text node for a given element, it > >> >> > is > >> >> > implicitly mixed content.... > >> >> > > >> >> > The basic syntax is as follows > >> >> > // assuming vn is an instance of VTDNav > >> >> > ti = new textIter(vn); > >> >> > while( (int i= ti.getNext())!= -1){ > >> >> > // i is the text node associated with the element at the cursor > >> >> > //position > >> >> > system.out.println("text node is ==> "+vn.toString(i)); > >> >> > } > >> >> > > >> >> > > >> >> > ----- Original Message ----- > >> >> > From: "Paul Tomsic" <pt...@gm...> > >> >> > To: <vtd...@li...> > >> >> > Sent: Wednesday, November 15, 2006 7:56 AM > >> >> > Subject: [Vtd-xml-users] mixed content? > >> >> > > >> >> > > >> >> >>i need a way, if given an XML document, to determine if a node was > >> >> >> marked as mixed=true in the schema. if it was, then return it's > >> >> >> children nodes as text. is this possible within vtd? > >> >> >> > >> >> >> The reason for this is b/c we've got "rich text" or "html" in XML > >> >> >> documents, and need a way to determine what is a child node, and > >> >> >> what's intended to be html. > >> >> >> > >> >> >> Something like > >> >> >> > >> >> >> <foo><em>emphasis</em> and some <b>bold</b> text as well</foo> > >> >> >> > >> >> >> So <foo> would be marked as mixed=true, then i'd return the > >> >> >> contents > >> >> >> between the foo elements. > >> >> >> > >> >> >> is there a better/more standard way to do this (short of marking it > >> >> >> all as CDATA) ? > >> >> >> > >> >> >> i can't seem to find a decent way to do what i'm trying to do. > >> >> >> thanks > >> >> >> > >> >> >> ------------------------------------------------------------------------- > >> >> >> Take Surveys. Earn Cash. Influence the Future of IT > >> >> >> Join SourceForge.net's Techsay panel and you'll get the chance to > >> >> >> share > >> >> >> your > >> >> >> opinions on IT & business topics through brief surveys - and earn > >> >> >> cash > >> >> >> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > >> >> >> _______________________________________________ > >> >> >> Vtd-xml-users mailing list > >> >> >> Vtd...@li... > >> >> >> https://lists.sourceforge.net/lists/listinfo/vtd-xml-users > >> >> >> > >> >> > > >> >> > > >> >> > > >> >> > ------------------------------------------------------------------------- > >> >> > Take Surveys. Earn Cash. Influence the Future of IT > >> >> > Join SourceForge.net's Techsay panel and you'll get the chance to > >> >> > share > >> >> > your > >> >> > opinions on IT & business topics through brief surveys - and earn > >> >> > cash > >> >> > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > >> >> > _______________________________________________ > >> >> > Vtd-xml-users mailing list > >> >> > Vtd...@li... > >> >> > https://lists.sourceforge.net/lists/listinfo/vtd-xml-users > >> >> > > >> >> > >> >> > >> >> > >> > > >> > >> > >> > > > > > |