All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sf.saxon.tree.util.ProcInstParser Maven / Gradle / Ivy

There is a newer version: 10.5
Show newest version
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2013 Saxonica Limited.
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

package net.sf.saxon.tree.util;

/**
  * ProcInstParser is used to parse pseudo-attributes within Processing Instructions
  * @author Michael H. Kay
  * @version 10 July 2000
  */
  

public class ProcInstParser {

    /**
     * Class is never instantiated
     */

    private ProcInstParser() {
    }

    /**
    * Get a pseudo-attribute. This is useful only if the processing instruction data part
    * uses pseudo-attribute syntax, which it does not have to. This syntax is as described
    * in the W3C Recommendation "Associating Style Sheets with XML Documents".
    * @return the value of the pseudo-attribute if present, or null if not
    */

    /*@Nullable*/ public static String getPseudoAttribute(/*@NotNull*/ String content, /*@NotNull*/ String name) {

        int pos = 0;
        while (pos <= content.length()-4) {     // minimum length of x=""
            int nextQuote = -1;
            for (int q=pos; q');
                    i+=3;
                } else if (value.substring(i+1).startsWith("amp;")) {
                    sb.append('&');
                    i+=4;
                } else if (value.substring(i+1).startsWith("quot;")) {
                    sb.append('"');
                    i+=5;
                } else if (value.substring(i+1).startsWith("apos;")) {
                    sb.append('\'');
                    i+=5;
                } else {
                    return null;
                }

            } else {
                sb.append(c);
            }
        }
        return sb.toString();
    }
                                      
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy