You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2004/04/13 17:04:38 UTC

cvs commit: cocoon-lenya/src/java/org/apache/lenya/cms/publication XlinkCollection.java

andreas     2004/04/13 08:04:38

  Modified:    src/java/org/apache/lenya/cms/publication
                        XlinkCollection.java
  Log:
  using constant for XLink namespace URI
  
  Revision  Changes    Path
  1.3       +22 -18    cocoon-lenya/src/java/org/apache/lenya/cms/publication/XlinkCollection.java
  
  Index: XlinkCollection.java
  ===================================================================
  RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/publication/XlinkCollection.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XlinkCollection.java	10 Mar 2004 09:20:56 -0000	1.2
  +++ XlinkCollection.java	13 Apr 2004 15:04:38 -0000	1.3
  @@ -19,9 +19,9 @@
   
   import java.io.IOException;
   
  -
   import org.apache.lenya.xml.NamespaceHelper;
   import org.apache.lenya.xml.DocumentHelper;
  +import org.apache.lenya.xml.XLink;
   import org.apache.log4j.Category;
   import org.w3c.dom.Element;
   
  @@ -29,7 +29,7 @@
    * Implementation of a Collection. In the collection are xlink inserted.
    */
   public class XlinkCollection extends CollectionImpl {
  -    
  +
       private static final Category log = Category.getInstance(XlinkCollection.class);
   
       /**
  @@ -39,7 +39,8 @@
        * @param area The area the document belongs to.
        * @throws DocumentException when something went wrong.
        */
  -    public XlinkCollection(Publication publication, String id, String area) throws DocumentException {
  +    public XlinkCollection(Publication publication, String id, String area)
  +        throws DocumentException {
           super(publication, id, area);
       }
   
  @@ -51,25 +52,26 @@
        * @param language The language of the document.
        * @throws DocumentException when something went wrong.
        */
  -    public XlinkCollection(Publication publication, String id, String area, String language) throws DocumentException {
  +    public XlinkCollection(Publication publication, String id, String area, String language)
  +        throws DocumentException {
           super(publication, id, area, language);
       }
   
       /** (non-Javadoc)
  -	 * @see org.apache.lenya.cms.publication.CollectionImpl#createDocumentElement(org.apache.lenya.cms.publication.Document, org.apache.lenya.xml.NamespaceHelper)
  -	 **/
  -	protected Element createDocumentElement(Document document, NamespaceHelper helper)
  +     * @see org.apache.lenya.cms.publication.CollectionImpl#createDocumentElement(org.apache.lenya.cms.publication.Document, org.apache.lenya.xml.NamespaceHelper)
  +     **/
  +    protected Element createDocumentElement(Document document, NamespaceHelper helper)
           throws DocumentException {
           Element element = super.createDocumentElement(document, helper);
           String path = null;
           try {
  -			path = document.getFile().getCanonicalPath();
  -		} catch (IOException e) {
  -            log.error("Couldn't found the file path for the document: "+document.getId()); 
  -		} 
  -        element.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", path);          
  -        element.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", "embed");
  -                  
  +            path = document.getFile().getCanonicalPath();
  +        } catch (IOException e) {
  +            log.error("Couldn't found the file path for the document: " + document.getId());
  +        }
  +        element.setAttributeNS(XLink.XLINK_NAMESPACE, "xlink:href", path);
  +        element.setAttributeNS(XLink.XLINK_NAMESPACE, "xlink:show", "embed");
  +
           return element;
       }
   
  @@ -79,12 +81,14 @@
        */
       public void save() throws DocumentException {
           try {
  -            
               NamespaceHelper helper = getNamespaceHelper();
               Element collectionElement = helper.getDocument().getDocumentElement();
  -              
  -            if ((collectionElement.getAttribute("xmlns:xlink") == null) | (!collectionElement.getAttribute("xmlns:xlink").equals("http://www.w3.org/1999/xlink"))) {
  -                collectionElement.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink");
  +
  +            if ((collectionElement.getAttribute("xmlns:xlink") == null)
  +                | (!collectionElement
  +                    .getAttribute("xmlns:xlink")
  +                    .equals("http://www.w3.org/1999/xlink"))) {
  +                collectionElement.setAttribute("xmlns:xlink", XLink.XLINK_NAMESPACE);
               }
               DocumentHelper.writeDocument(helper.getDocument(), getFile());
               super.save();
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-cvs-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-cvs-help@cocoon.apache.org