Package de.danet.an.util.web

Source Code of de.danet.an.util.web.CocoonUtil

/*
* This file is part of the WfMOpen project.
* Copyright (C) 2001-2003 Danet GmbH (www.danet.de), GS-AN.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*
* $Id: CocoonUtil.java 1607 2006-09-29 12:32:13Z drmlipp $
*
* $Log$
* Revision 1.1.1.1  2003/06/30 20:05:12  drmlipp
* Initial import
*
* Revision 1.3  2003/06/27 08:51:46  lipp
* Fixed copyright/license information.
*
* Revision 1.2  2003/04/24 20:50:13  lipp
* Fixed some warnings.
*
* Revision 1.1  2001/12/19 11:48:42  lipp
* XSP debug feature.
*
*/

package de.danet.an.util.web;

import org.w3c.dom.Document;
import org.w3c.dom.ProcessingInstruction;

/**
* Utilities for cocoon.
*/
public class CocoonUtil {

    /**
     * Looks for the processing instruction "xml-stylesheet" and
     * replaces the value of href.
     * @param doc the document to look in.
     * @param newSheet the new value for href.
     */
    public static void replaceStylesheet (Document doc, String newSheet) {
        ProcessingInstruction pi = W3CDomUtil.findFirstPI
      (doc, "xml-stylesheet");
        if (pi == null) {
      return;
  }
  String dataIn = pi.getData();
  String dataOut;
  int scanPos = dataIn.indexOf("href=\"");
  if (scanPos < 0) {
      return;
  }
  scanPos = scanPos + 6;
  dataOut = dataIn.substring(0, scanPos) + newSheet;
  scanPos = dataIn.indexOf('\"', scanPos);
  dataOut = dataOut + dataIn.substring(scanPos);
  pi.setData(dataOut);
    }

}
TOP

Related Classes of de.danet.an.util.web.CocoonUtil

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.