Search in sources :

Example 46 with SAXParser

use of javax.xml.parsers.SAXParser in project intellij-community by JetBrains.

the class XmlConstraintsTest method getXSModel.

private XSModel getXSModel(String... files) {
    myFixture.configureByFiles(files);
    XmlFile file = (XmlFile) myFixture.getFile();
    ValidateXmlActionHandler handler = new ValidateXmlActionHandler(false) {

        @Override
        protected SAXParser createParser() throws SAXException, ParserConfigurationException {
            SAXParser parser = super.createParser();
            parser.getXMLReader().setFeature(Constants.XERCES_FEATURE_PREFIX + Constants.CONTINUE_AFTER_FATAL_ERROR_FEATURE, true);
            return parser;
        }
    };
    handler.setErrorReporter(new TestErrorReporter(handler));
    handler.doValidate(file);
    XMLGrammarPool grammarPool = ValidateXmlActionHandler.getGrammarPool(file);
    assert grammarPool != null;
    Grammar[] grammars = grammarPool.retrieveInitialGrammarSet(XMLGrammarDescription.XML_SCHEMA);
    XSGrammar grammar = (XSGrammar) grammars[0];
    return grammar.toXSModel();
}
Also used : XMLGrammarPool(org.apache.xerces.xni.grammars.XMLGrammarPool) TestErrorReporter(com.intellij.xml.actions.validate.TestErrorReporter) XmlFile(com.intellij.psi.xml.XmlFile) XSGrammar(org.apache.xerces.xni.grammars.XSGrammar) SAXParser(javax.xml.parsers.SAXParser) ValidateXmlActionHandler(com.intellij.xml.actions.validate.ValidateXmlActionHandler) Grammar(org.apache.xerces.xni.grammars.Grammar) XSGrammar(org.apache.xerces.xni.grammars.XSGrammar)

Example 47 with SAXParser

use of javax.xml.parsers.SAXParser in project intellij-community by JetBrains.

the class SvnParseCommandLineParseTest method testStatusWithSwitched.

public void testStatusWithSwitched() throws Exception {
    final String s = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<status>\n" + "<target\n" + "   path=\".\">\n" + "<entry\n" + "   path=\"root\\source\\s1.txt\">\n" + "<wc-status\n" + "   props=\"none\"\n" + "   switched=\"true\"\n" + "   item=\"normal\"\n" + "   revision=\"5\">\n" + "<commit\n" + "   revision=\"4\">\n" + "<author>Irina.Chernushina</author>\n" + "<date>2013-02-18T13:14:24.391537Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"root\\target\">\n" + "<wc-status\n" + "   props=\"none\"\n" + "   switched=\"true\"\n" + "   item=\"normal\"\n" + "   revision=\"5\">\n" + "<commit\n" + "   revision=\"4\">\n" + "<author>Irina.Chernushina</author>\n" + "<date>2013-02-18T13:14:24.391537Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "</target>\n" + "</status>";
    final SvnStatusHandler[] handlerArr = new SvnStatusHandler[1];
    final boolean isWindows = SystemInfo.isWindows;
    final String basePath = isWindows ? "C:/base/" : "/base33729/";
    final Set<PortableStatus> statuses = new HashSet<>();
    final SvnStatusHandler handler = new SvnStatusHandler(new SvnStatusHandler.ExternalDataCallback() {

        @Override
        public void switchPath() {
            statuses.add(handlerArr[0].getPending());
            handlerArr[0].getPending().getKind();
        }

        @Override
        public void switchChangeList(String newList) {
        }
    }, new File(basePath), o -> {
        try {
            o.getCanonicalFile();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        if (isWindows) {
            final int idx = o.getPath().indexOf(":");
            Assert.assertTrue(idx > 0);
            final int secondIdx = o.getPath().indexOf(":", idx + 1);
            Assert.assertTrue(o.getPath(), secondIdx == -1);
        } else {
            if (o.getPath().contains(LINUX_ROOT)) {
                Assert.assertFalse(o.getPath().contains(basePath));
            }
        }
        try {
            return createStubInfo(basePath + "1", "http://a.b.c");
        } catch (SVNException e) {
            throw new RuntimeException(e);
        }
    });
    handlerArr[0] = handler;
    final String osChecked = changePathsIfNix(s);
    SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
    parser.parse(new ByteArrayInputStream(osChecked.getBytes(CharsetToolkit.UTF8_CHARSET)), handler);
    final String[] expected = { "root\\source\\s1.txt", "root\\target" };
    for (int i = 0; i < expected.length; i++) {
        expected[i] = FileUtil.toSystemDependentName(expected[i]);
    }
    int cntMatched = 0;
    for (PortableStatus status : statuses) {
        Assert.assertTrue(status.isSwitched());
        final String path = FileUtil.toSystemDependentName(status.getPath());
        for (String s1 : expected) {
            if (s1.equals(path)) {
                ++cntMatched;
                break;
            }
        }
    }
    Assert.assertEquals(2, cntMatched);
}
Also used : PortableStatus(org.jetbrains.idea.svn.status.PortableStatus) IOException(java.io.IOException) SVNException(org.tmatesoft.svn.core.SVNException) ByteArrayInputStream(java.io.ByteArrayInputStream) SvnStatusHandler(org.jetbrains.idea.svn.status.SvnStatusHandler) SAXParser(javax.xml.parsers.SAXParser) File(java.io.File) HashSet(java.util.HashSet)

Example 48 with SAXParser

use of javax.xml.parsers.SAXParser in project intellij-community by JetBrains.

the class SvnParseCommandLineParseTest method testStatus.

public void testStatus() throws Exception {
    final String s = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<status>\n" + "<target\n" + "   path=\".\">\n" + "<entry\n" + "   path=\".\">\n" + "<wc-status\n" + "   props=\"normal\"\n" + "   item=\"incomplete\"\n" + "   revision=\"92339\">\n" + "<commit\n" + "   revision=\"91672\">\n" + "<author>qx</author>\n" + "<date>2012-01-27T16:11:06.069351Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"Decompiler\">\n" + "<wc-status\n" + "   props=\"none\"\n" + "   tree-conflicted=\"true\"\n" + "   item=\"missing\">\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"Help\">\n" + "<wc-status\n" + "   props=\"normal\"\n" + "   item=\"incomplete\"\n" + "   revision=\"92339\">\n" + "<commit\n" + "   revision=\"91555\">\n" + "<author>Egor.Malyshev</author>\n" + "<date>2012-01-18T18:05:07.328519Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"Help\\XML\">\n" + "<wc-status\n" + "   props=\"normal\"\n" + "   item=\"incomplete\"\n" + "   revision=\"92339\">\n" + "<commit\n" + "   revision=\"91555\">\n" + "<author>Egor.Malyshev</author>\n" + "<date>2012-01-18T18:05:07.328519Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"Help\\XML\\images\">\n" + "<wc-status\n" + "   props=\"normal\"\n" + "   item=\"incomplete\"\n" + "   revision=\"92339\">\n" + "<commit\n" + "   revision=\"91170\">\n" + "<author>Maria.Egorkina</author>\n" + "<date>2011-12-20T13:26:52.217550Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"Platform\">\n" + "<wc-status\n" + "   props=\"none\"\n" + "   item=\"external\">\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"ReSharper.ipr\">\n" + "<wc-status\n" + "   item=\"modified\"\n" + "   revision=\"91677\"\n" + "   props=\"normal\">\n" + "<commit\n" + "   revision=\"87631\">\n" + "<author>Alexey.Kuptsov</author>\n" + "<date>2011-09-30T11:25:10.391467Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"ReSharper.iws\">\n" + "<wc-status\n" + "   item=\"ignored\"\n" + "   props=\"none\">\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"measure.bat\">\n" + "<wc-status\n" + "   item=\"unversioned\"\n" + "   props=\"none\">\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"src\\Daemon\\src\\HighlightingBase.cs\">\n" + "<wc-status\n" + "   item=\"deleted\"\n" + "   revision=\"91677\"\n" + "   props=\"none\">\n" + "<commit\n" + "   revision=\"79264\">\n" + "<author>xvost</author>\n" + "<date>2011-02-05T16:06:12.116814Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"src\\Daemon\\src\\HighlightingBase1.cs\">\n" + "<wc-status\n" + "   props=\"none\"\n" + "   copied=\"true\"\n" + "   item=\"added\">\n" + "<commit\n" + "   revision=\"79264\">\n" + "<author>xvost</author>\n" + "<date>2011-02-05T16:06:12.116814Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"src\\Decompiler.Core\">\n" + "<wc-status\n" + "   item=\"added\"\n" + "   props=\"normal\"\n" + "   copied=\"true\"\n" + "   tree-conflicted=\"true\">\n" + "<commit\n" + "   revision=\"91559\">\n" + "<author>Leonid.Shalupov</author>\n" + "<date>2012-01-18T19:17:40.876383Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"src\\Decompiler.Core\\Src\\Transformations\\Loops\\EliminateRedundantContinueTransformation.cs\">\n" + "<wc-status\n" + "   props=\"normal\"\n" + "   copied=\"true\"\n" + "   item=\"modified\">\n" + "<commit\n" + "   revision=\"87972\">\n" + "<author>Slava.Trenogin</author>\n" + "<date>2011-10-06T21:27:41.539022Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"src\\Decompiler.Core\\Src\\Transformations\\StatementStructure\\ReduceReturnOrYieldBreakTransformation.cs\">\n" + "<wc-status\n" + "   item=\"modified\"\n" + "   props=\"normal\"\n" + "   copied=\"true\">\n" + "<commit\n" + "   revision=\"87972\">\n" + "<author>Slava.Trenogin</author>\n" + "<date>2011-10-06T21:27:41.539022Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"stat.txt\">\n" + "<wc-status\n" + "   props=\"none\"\n" + "   item=\"unversioned\">\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\CommonServices\\src\\Services\\CommonServices.cs\">\n" + "<wc-status\n" + "   item=\"modified\"\n" + "   revision=\"92564\"\n" + "   props=\"none\">\n" + "<commit\n" + "   revision=\"73708\">\n" + "<author>Leonid.Shalupov</author>\n" + "<date>2010-09-10T14:14:04.090943Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Document.Tests\\AssemblyInfo.cs\">\n" + "<wc-status\n" + "   item=\"modified\"\n" + "   revision=\"92564\"\n" + "   props=\"none\">\n" + "<commit\n" + "   revision=\"86795\">\n" + "<author>Leonid.Shalupov</author>\n" + "<date>2011-09-11T13:54:16.917943Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Document.Tests\\RangeMarkerTest.cs\">\n" + "<wc-status\n" + "   props=\"none\"\n" + "   item=\"modified\"\n" + "   revision=\"92564\">\n" + "<commit\n" + "   revision=\"77688\">\n" + "<author>Alexander.Zverev</author>\n" + "<date>2010-12-14T15:56:38.322018Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\AssemblyInfo.cs\">\n" + "<wc-status\n" + "   item=\"modified\"\n" + "   revision=\"92564\"\n" + "   props=\"none\">\n" + "<commit\n" + "   revision=\"82127\">\n" + "<author>Leonid.Shalupov</author>\n" + "<date>2011-04-13T20:57:30.828600Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\src\\Utils\\AssemblyNameInfo.cs\">\n" + "<wc-status\n" + "   item=\"modified\"\n" + "   revision=\"92564\"\n" + "   props=\"none\">\n" + "<commit\n" + "   revision=\"90865\">\n" + "<author>xvost</author>\n" + "<date>2011-12-13T13:10:30.902950Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\src\\Utils\\BinaryBlobExtensions.cs\">\n" + "<wc-status\n" + "   item=\"modified\"\n" + "   revision=\"92564\"\n" + "   props=\"none\">\n" + "<commit\n" + "   revision=\"74075\">\n" + "<author>Leonid.Shalupov</author>\n" + "<date>2010-09-17T09:32:30.827654Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\src\\Utils\\BinaryBlobReader.cs\">\n" + "<wc-status\n" + "   props=\"none\"\n" + "   item=\"modified\"\n" + "   revision=\"92564\">\n" + "<commit\n" + "   revision=\"74075\">\n" + "<author>Leonid.Shalupov</author>\n" + "<date>2010-09-17T09:32:30.827654Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\src\\Utils\\BinaryBlobStream.cs\">\n" + "<wc-status\n" + "   props=\"none\"\n" + "   item=\"modified\"\n" + "   revision=\"92564\">\n" + "<commit\n" + "   revision=\"74075\">\n" + "<author>Leonid.Shalupov</author>\n" + "<date>2010-09-17T09:32:30.827654Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\src\\Utils\\BlobOnReader.cs\">\n" + "<wc-status\n" + "   item=\"modified\"\n" + "   revision=\"92564\"\n" + "   props=\"none\">\n" + "<commit\n" + "   revision=\"74075\">\n" + "<author>Leonid.Shalupov</author>\n" + "<date>2010-09-17T09:32:30.827654Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\src\\Utils\\ComStreamWrapper.cs\">\n" + "<wc-status\n" + "   item=\"modified\"\n" + "   revision=\"92564\"\n" + "   props=\"none\">\n" + "<commit\n" + "   revision=\"91348\">\n" + "<author>Sergey.Shkredov</author>\n" + "<date>2012-01-09T11:26:53.770349Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\src\\Utils\\EmptyBlob.cs\">\n" + "<wc-status\n" + "   props=\"none\"\n" + "   item=\"modified\"\n" + "   revision=\"92564\">\n" + "<commit\n" + "   revision=\"74075\">\n" + "<author>Leonid.Shalupov</author>\n" + "<date>2010-09-17T09:32:30.827654Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\src\\Utils\\GAC.cs\">\n" + "<wc-status\n" + "   props=\"normal\"\n" + "   item=\"modified\"\n" + "   revision=\"92564\">\n" + "<commit\n" + "   revision=\"75626\">\n" + "<author>Slava.Trenogin</author>\n" + "<date>2010-10-21T07:41:45.036722Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\src\\Utils\\GacUtil.cs\">\n" + "<wc-status\n" + "   props=\"none\"\n" + "   item=\"modified\"\n" + "   revision=\"92564\">\n" + "<commit\n" + "   revision=\"91646\">\n" + "<author>Leonid.Shalupov</author>\n" + "<date>2012-01-21T19:08:04.108471Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\src\\Utils\\IBinaryReader.cs\">\n" + "<wc-status\n" + "   item=\"modified\"\n" + "   revision=\"92564\"\n" + "   props=\"none\">\n" + "<commit\n" + "   revision=\"71390\">\n" + "<author>Leonid.Shalupov</author>\n" + "<date>2010-07-12T18:29:27.763006Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\src\\Utils\\IntInterval.cs\">\n" + "<wc-status\n" + "   item=\"modified\"\n" + "   revision=\"92564\"\n" + "   props=\"none\">\n" + "<commit\n" + "   revision=\"55567\">\n" + "<author>qx</author>\n" + "<date>2009-06-03T10:11:14.985037Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\src\\Utils\\ManifestResourceUtil.cs\">\n" + "<wc-status\n" + "   props=\"none\"\n" + "   item=\"modified\"\n" + "   revision=\"92564\">\n" + "<commit\n" + "   revision=\"87972\">\n" + "<author>Slava.Trenogin</author>\n" + "<date>2011-10-06T21:27:41.539022Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\src\\Utils\\MarshalSpecParser.cs\">\n" + "<wc-status\n" + "   item=\"modified\"\n" + "   revision=\"92564\"\n" + "   props=\"none\">\n" + "<commit\n" + "   revision=\"76982\">\n" + "<author>Leonid.Shalupov</author>\n" + "<date>2010-11-28T10:16:36.309593Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\src\\Utils\\MetadataHelpers.cs\">\n" + "<wc-status\n" + "   props=\"none\"\n" + "   item=\"modified\"\n" + "   revision=\"92564\">\n" + "<commit\n" + "   revision=\"91348\">\n" + "<author>Sergey.Shkredov</author>\n" + "<date>2012-01-09T11:26:53.770349Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\src\\Utils\\ModuleQualificationUtil.cs\">\n" + "<wc-status\n" + "   props=\"none\"\n" + "   item=\"modified\"\n" + "   revision=\"92564\">\n" + "<commit\n" + "   revision=\"60918\">\n" + "<author>xvost</author>\n" + "<date>2009-11-03T10:42:37.363952Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\src\\Utils\\StreamBinaryReader.cs\">\n" + "<wc-status\n" + "   item=\"modified\"\n" + "   revision=\"92564\"\n" + "   props=\"none\">\n" + "<commit\n" + "   revision=\"71390\">\n" + "<author>Leonid.Shalupov</author>\n" + "<date>2010-07-12T18:29:27.763006Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\src\\Utils\\SubStream.cs\">\n" + "<wc-status\n" + "   item=\"modified\"\n" + "   revision=\"92564\"\n" + "   props=\"none\">\n" + "<commit\n" + "   revision=\"76725\">\n" + "<author>Leonid.Shalupov</author>\n" + "<date>2010-11-20T13:23:44.172899Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "</target>\n" + "<changelist\n" + "   name=\"ads\">\n" + "<entry\n" + "   path=\"BuildVsix.cmd\">\n" + "<wc-status\n" + "   item=\"modified\"\n" + "   revision=\"91677\"\n" + "   props=\"none\">\n" + "<commit\n" + "   revision=\"77579\">\n" + "<author>Victor.Kropp</author>\n" + "<date>2010-12-13T11:06:36.141754Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "</changelist>\n" + "</status>\n";
    final SvnStatusHandler[] handlerArr = new SvnStatusHandler[1];
    final boolean isWindows = SystemInfo.isWindows;
    final String basePath = isWindows ? "C:/base/" : "/base33729/";
    final SvnStatusHandler handler = new SvnStatusHandler(new SvnStatusHandler.ExternalDataCallback() {

        @Override
        public void switchPath() {
            handlerArr[0].getPending().getKind();
        }

        @Override
        public void switchChangeList(String newList) {
        }
    }, new File(basePath), o -> {
        try {
            o.getCanonicalFile();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        if (isWindows) {
            final int idx = o.getPath().indexOf(":");
            Assert.assertTrue(idx > 0);
            final int secondIdx = o.getPath().indexOf(":", idx + 1);
            Assert.assertTrue(o.getPath(), secondIdx == -1);
        } else {
            if (o.getPath().contains(LINUX_ROOT)) {
                Assert.assertFalse(o.getPath().contains(basePath));
            }
        }
        try {
            return createStubInfo(basePath + "1", "http://a.b.c");
        } catch (SVNException e) {
            throw new RuntimeException(e);
        }
    });
    handlerArr[0] = handler;
    final String osChecked = changePathsIfNix(s);
    SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
    parser.parse(new ByteArrayInputStream(osChecked.getBytes(CharsetToolkit.UTF8_CHARSET)), handler);
    final MultiMap<String, PortableStatus> changes = handler.getCurrentListChanges();
}
Also used : PortableStatus(org.jetbrains.idea.svn.status.PortableStatus) IOException(java.io.IOException) SVNException(org.tmatesoft.svn.core.SVNException) ByteArrayInputStream(java.io.ByteArrayInputStream) SvnStatusHandler(org.jetbrains.idea.svn.status.SvnStatusHandler) SAXParser(javax.xml.parsers.SAXParser) File(java.io.File)

Example 49 with SAXParser

use of javax.xml.parsers.SAXParser in project intellij-community by JetBrains.

the class SvnParseCommandLineParseTest method testInfo.

public void testInfo() throws Exception {
    final String s = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<info>\n" + "<entry\n" + "   path=\"ReduceReturnOrYieldBreakTransformation.cs\"\n" + "   revision=\"91603\"\n" + "   kind=\"file\">\n" + "<url>http://svn.labs.intellij.net/resharper/trunk/ReSharper/src/Decompiler.Core/Src/Transformations/StatementStructure/ReduceReturnOrYieldBreakTransformation.cs</url>\n" + "<repository>\n" + "<root>http://svn.labs.intellij.net/resharper</root>\n" + "<uuid>ed0594e5-7722-0410-9c76-949374689613</uuid>\n" + "</repository>\n" + "<wc-info>\n" + "<wcroot-abspath>C:/TestProjects/sortedProjects/Subversion/Resharper17short</wcroot-abspath>\n" + "<schedule>normal</schedule>\n" + "<depth>infinity</depth>\n" + "<text-updated>2012-01-20T11:25:32.625000Z</text-updated>\n" + "<checksum>7af8adacb93afaa48b2cfb76de605824c220983a</checksum>\n" + "</wc-info>\n" + "<commit\n" + "   revision=\"87972\">\n" + "<author>Slava.Trenogin</author>\n" + "<date>2011-10-06T21:27:41.539022Z</date>\n" + "</commit>\n" + "</entry>\n" + "</info>";
    final Info[] info = new Info[1];
    final SvnInfoHandler handler = new SvnInfoHandler(new File("C:/base/"), info1 -> info[0] = info1);
    SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
    parser.parse(new ByteArrayInputStream(s.getBytes(CharsetToolkit.UTF8_CHARSET)), handler);
    Assert.assertNotNull(info[0]);
}
Also used : SvnInfoHandler(org.jetbrains.idea.svn.info.SvnInfoHandler) ByteArrayInputStream(java.io.ByteArrayInputStream) SAXParser(javax.xml.parsers.SAXParser) Info(org.jetbrains.idea.svn.info.Info) SystemInfo(com.intellij.openapi.util.SystemInfo) File(java.io.File)

Example 50 with SAXParser

use of javax.xml.parsers.SAXParser in project intellij-community by JetBrains.

the class ValidateXmlActionHandler method createParser.

protected SAXParser createParser() throws SAXException, ParserConfigurationException {
    if (!needsDtdChecking() && !needsSchemaChecking() && !myForceChecking) {
        return null;
    }
    SAXParserFactory factory = new SAXParserFactoryImpl();
    boolean schemaChecking = false;
    if (hasDtdDeclaration()) {
        factory.setValidating(true);
    }
    if (needsSchemaChecking()) {
        factory.setValidating(true);
        factory.setNamespaceAware(true);
        //jdk 1.5 API
        try {
            factory.setXIncludeAware(true);
        } catch (NoSuchMethodError ignore) {
        }
        schemaChecking = true;
    }
    try {
        factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
    } catch (Exception ignore) {
    }
    SAXParser parser = factory.newSAXParser();
    parser.setProperty(ENTITY_RESOLVER_PROPERTY_NAME, myXmlResourceResolver);
    try {
        parser.getXMLReader().setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
    } catch (Exception ignore) {
    }
    if (schemaChecking) {
        // when dtd checking schema refs could not be validated @see http://marc.theaimsgroup.com/?l=xerces-j-user&m=112504202423704&w=2
        XMLGrammarPool grammarPool = getGrammarPool(myFile, myForceChecking);
        configureEntityManager(myFile, parser);
        parser.getXMLReader().setProperty(GRAMMAR_FEATURE_ID, grammarPool);
    }
    try {
        if (schemaChecking) {
            parser.setProperty(JAXPConstants.JAXP_SCHEMA_LANGUAGE, JAXPConstants.W3C_XML_SCHEMA);
            parser.getXMLReader().setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, true);
            if (Boolean.TRUE.equals(Boolean.getBoolean(XmlResourceResolver.HONOUR_ALL_SCHEMA_LOCATIONS_PROPERTY_KEY))) {
                parser.getXMLReader().setFeature("http://apache.org/xml/features/honour-all-schemaLocations", true);
            }
            parser.getXMLReader().setFeature("http://apache.org/xml/features/validation/warn-on-undeclared-elemdef", Boolean.TRUE);
            parser.getXMLReader().setFeature("http://apache.org/xml/features/validation/warn-on-duplicate-attdef", Boolean.TRUE);
        }
        parser.getXMLReader().setFeature("http://apache.org/xml/features/warn-on-duplicate-entitydef", Boolean.TRUE);
        parser.getXMLReader().setFeature("http://apache.org/xml/features/validation/unparsed-entity-checking", Boolean.FALSE);
    } catch (SAXNotRecognizedException ex) {
        // it is possible to continue work with configured parser
        LOG.info("Xml parser installation seems screwed", ex);
    }
    return parser;
}
Also used : XMLGrammarPool(org.apache.xerces.xni.grammars.XMLGrammarPool) SAXParserFactoryImpl(org.apache.xerces.jaxp.SAXParserFactoryImpl) SAXParser(javax.xml.parsers.SAXParser) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXParserFactory(javax.xml.parsers.SAXParserFactory)

Aggregations

SAXParser (javax.xml.parsers.SAXParser)235 SAXParserFactory (javax.xml.parsers.SAXParserFactory)142 SAXException (org.xml.sax.SAXException)112 InputSource (org.xml.sax.InputSource)95 IOException (java.io.IOException)80 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)71 DefaultHandler (org.xml.sax.helpers.DefaultHandler)37 XMLReader (org.xml.sax.XMLReader)36 File (java.io.File)35 ByteArrayInputStream (java.io.ByteArrayInputStream)28 StringReader (java.io.StringReader)27 InputStream (java.io.InputStream)24 Attributes (org.xml.sax.Attributes)22 SAXSource (javax.xml.transform.sax.SAXSource)17 SAXParseException (org.xml.sax.SAXParseException)17 ArrayList (java.util.ArrayList)13 JAXBContext (javax.xml.bind.JAXBContext)12 Unmarshaller (javax.xml.bind.Unmarshaller)12 FileNotFoundException (java.io.FileNotFoundException)10 ValidationEvent (javax.xml.bind.ValidationEvent)9