List Info

Thread: caching XmlObjects for a changing XML document




caching XmlObjects for a changing XML document
country flaguser name
United States
2007-06-11 14:37:11

I am reading an XML schema file as an XML document and modifying it per my project needs. Modification happens in several places and in most places modification is of the nature: remove SchemaProperty ‘prop’ from SchemaType ‘type’.

 

So the flow of my program is roughly:

 

main()

{

     XmlObject doc = XmlObject.Factory.parse(inputSchemaFile)

     SchemaTypeSystem sts = XmlBeans.compileXsd(doc, …)

    

     Now I begin processing sts and call

         removeProperty (doc, schemaType,  schemaProperty)

     in several places

    

     When done, save doc as new schema file.

}

 

removeProperty (XmlObject doc, SchemaType type, SchemaProperty prop)

{

    XmlObject xoType = doc.selectPath (xpath for type)

    XmlObejct xoProp = xoType.selectPath (xpath for prop)

    Node domNode = xoProp.getDomNode()

    domNode.getParentNode().removeChild(domNode)

}

 

I am finding that selectPath seems to be very expensive. So I wanted to cache the XmlObjects for types, such that in future if xpath is same, I can return from my local cache instead of calling selectPath.

 

My question is in this dynamic situation where I am changing the underlying XML instance (via removeProperty call above), will caching XmlObject(s) work?

   

        

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )