+0

Vincent Massol wrote:
> Hi,
>
> Following the previously aborted vote, here's a new proposal. The  
> problem with the current implementation is that you cannot write:
>
> for (LinkBlock block : xdom.getChildrenByType(LinkBlock.class, true)) {
>            Block newBlock = new  
> FormatBlock(Collections.<Block>singletonList(block), Format.ITALIC);
>            block.replace(newBlock);
>        }
>
> This fails because when the "block" is added in FormatBlock, its  
> parent is set to be the FormatBlock and thus when block.replace()  
> executes the parent of the new block is set to be the format block  
> instead of its parent.
>
> I thus propose an API that is inline with the w3c DOM API:
>
>      /**
>       * Replaces an existing children block with the passed new block.
>       * Also sets the new block's parent to be the current block.
>       *
>       * @param newBlock the new block to replace the old block with
>       */
>      void replaceChild(Block newBlock, Block oldBlock);
>
>      /**
>       * Replaces an existing children block with the passed new blocks.
>       * Also sets the new block's parents to be the current block.
>       *
>       * @param newBlocks the new blocks to replace the old block with
>       */
>      void replaceChild(List<Block> newBlocks, Block oldBlock);
>
>
> Note for Sergiu (before he asks ;)):
> - We had evaluated using either the w3c Node API or the JCR Node API  
> before we created our own Block API.
> - We cannot use the w3c Node interface since it contains too many  
> references to XML (like CDATA, ProcessingInstruction, etc)
> - We cannot use the JCR Node API since it's too complex and contains  
> references to mixins, etc.
>
> Here's my +1
>
> Thanks
> -Vincent
>
> _______________________________________________
> devs mailing list
> [email protected]
> http://lists.xwiki.org/mailman/listinfo/devs

_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to