Hi, Jacob,
Thanks for your thought. The reason to split them into multiple files is to
share content. For example, I may have the following "import" chains:
File A <-- File B <-- File C (B imports A and C imports B)
File A <-- File B <-- File D (B imports A and D imports B)
File A <-- File E (E imports A)
I am doing read-only parsing only for these XMLs and do not want to
duplicate A's content to other files.
Another thought is whether I can use XLink to refer to an external XML with
XMLBean. I am new to XMLBean and looking into possible solutions.
Thanks for the help again!
Bo
On 6/12/07, Jacob Danner <[EMAIL PROTECTED]> wrote:
Hi Bo,
I guess the complete answer is there is no EASY way to do this. You
might be able to HACKHACK something together using XmlCursor APIs like
XmlCursor.copyXml(...) or copyXmlContents(...).
I've gotta wonder if maybe you aren't making this more difficult on
yourself by not using standard XML features.
If you've designed your schema as such you might be able to do
something like this:
<xsd:element name="composite">
...
<xsd:element ref="aType"/>
<xsd:element ref="bType"/>
<xsd:element ref="cType"/>
...
File AXml = // <a />
...
AType AXmlInstance = AType.Factory.parse(AXml);
...
CompositeDocument c = CompositeDocument.Factory.newInstance();
c. /// other init stuff
s.setAType(AXmlInstance);
s.setBType(BXmlInstance);
-Jacob Danner
On 6/12/07, Bo Wen <[EMAIL PROTECTED]> wrote:
> Thanks Jacob! So there is no way to parse multiple XMLs through XMLBean
and
> I have to concatenate them. It would be nice if XMLBean could do that.
>
> Thanks again!
>
> Bo
>
> On 6/12/07, Jacob Danner <[EMAIL PROTECTED]> wrote:
> > Hi Bo,
> > This will not work as a new XmlObject (think xml instance) is created
> > on each call.
> > > XmlObject.Factory.parse(FileA);
> > > XmlObject.Factory.parse(FileB);
> > > XmlObject.Factory.parse(FileC);
> >
> > If you concatenate into one instance that should work.
> > -Jacob Danner
> >
> > On 6/12/07, Bo Wen <[EMAIL PROTECTED]> wrote:
> > > Thanks for the reply. You are right. <import/> is just a normal
tag
> and
> > > from my own schema. I don't expect any parser understand that. I
will
> need
> > > to manually load all imported files into memory and treat them as a
> single
> > > XML in memory for navigation. I will have to write special logic to
> > > interpret <import/>.
> > >
> > > For example, File A imports File B and File B import File C. I want
to
> load
> > > File A, B and C together into memory as a single XML. So, can I do
> this:
> > > XmlObject.Factory.parse (FileA);
> > > XmlObject.Factory.parse(FileB);
> > > XmlObject.Factory.parse(FileC);
> > > Will this load 3 XML files into memory as a single XML?
> > >
> > > If not, as a workaround, I can do pre-process: concatenate File A, B
and
> C
> > > into a single File X based on <import/> tag. Then use
> > > "XmlObject.Factory.parse(FileX)" to load it into memory for
havigation.
> Or
> > > is there a better way?
> > >
> > > I am curious how Ant does this for its multiple build files using
> <import/>.
> > > I am sure Ant does not use XMLBean.
> > >
> > > Thanks,
> > > Bo
> > >
> > >
> > >
> > > On 6/12/07, Jacob Danner <[EMAIL PROTECTED]> wrote:
> > > >
> > > > Hi Bo,
> > > > I'm not sure I completely understand the question, but I'll give
it a
> > > shot.
> > > > If you are trying to do something like
> > > > XmlObject.Factory.parse (<instanceDocument/>);
> > > > My guess is your <import /> tag won't work as you expect it to
because
> > > > its not part of the normal XML grammar (AFAIK) and the parser
won't
> > > > know what to do with it.
> > > > Do you know of another parser that works with this? In other
words,
> > > > how are you making your <import /> element work currently?
> > > >
> > > > Thanks,
> > > > -Jacob Danner
> > > >
> > > > On 6/12/07, Bo Wen <[EMAIL PROTECTED]> wrote:
> > > > > Hi, All,
> > > > >
> > > > > I have multiple XML files related through my own <import> tag.
> These
> > > files
> > > > > share same schema. This is used to support content sharing and
> > > inheritance
> > > > > like features. Put another way, it is like <import> tag in Ant
> build
> > > file.
> > > > >
> > > > > Can XMLBean load and parse multiple XMLs at one time? If not, I
> will
> > > try to
> > > > > concatenate multiple XMLs into a single file based on <import>
tag,
> then
> > > use
> > > > > XMLBean to parse. Or is there a better solution?
> > > > >
> > > > > Thanks in advance!
> > > > > Bo
> > > > >
> > > >
> > > >
> > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail:
> > > [EMAIL PROTECTED]
> > > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > >
> > > >
> > >
> > >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]