├── .classpath
├── .gitignore
├── .project
├── .settings
├── org.eclipse.core.resources.prefs
├── org.eclipse.core.runtime.prefs
├── org.eclipse.jdt.core.prefs
├── org.eclipse.jdt.launching.prefs
├── org.eclipse.jdt.ui.prefs
└── org.eclipse.m2e.core.prefs
├── JUnitHttpProxy.http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FC%2B%2B_%28programming_language%29.tmp
├── JUnitHttpProxy.http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FC_%28programming_language%29.tmp
├── JUnitHttpProxy.http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FJava_%28programming_language%29.tmp
├── JUnitHttpProxy.http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FScala_%28programming_language%29.tmp
├── JUnitHttpProxy.http%3A%2F%2Fmaps.google.com%2Fmaps%2Fapi%2Fgeocode%2Fxml%3Faddress%3DInfinite%2520Loop%2C%2520Cupertino%2C%2520CA%252095014%2C%2520USA%2522.tmp
├── JUnitHttpProxy.http%3A%2F%2Fweather.service.msn.com%2Ffind.aspx%3Foutputview%3Dsearch%26weasearchstr%3DMonschau.tmp
├── LICENSE
├── README.md
├── doc
├── API_Landscape.svg
├── API_Landscape.xgml
├── API_Landscape1.svg
├── XBProjector-Sheet.graphml
└── XMLBeam.mm
├── logging.properties
├── make_bundle.sh
├── pom.xml
├── src
├── main
│ ├── java
│ │ └── org
│ │ │ └── xmlbeam
│ │ │ ├── AutoList.java
│ │ │ ├── AutoMap.java
│ │ │ ├── AutoValue.java
│ │ │ ├── DefaultDOMAccessInvoker.java
│ │ │ ├── DefaultFileIO.java
│ │ │ ├── DefaultFileList.java
│ │ │ ├── DefaultFileMap.java
│ │ │ ├── DefaultFileValue.java
│ │ │ ├── DefaultXPathBinder.java
│ │ │ ├── DomChangeTracker.java
│ │ │ ├── MethodSignature.java
│ │ │ ├── MixinHolder.java
│ │ │ ├── ProjectionFactory.java
│ │ │ ├── ProjectionFactoryConfig.java
│ │ │ ├── ProjectionInvocationHandler.java
│ │ │ ├── XBProjector.java
│ │ │ ├── annotation
│ │ │ ├── XBAuto.java
│ │ │ ├── XBDelete.java
│ │ │ ├── XBDocURL.java
│ │ │ ├── XBOverride.java
│ │ │ ├── XBRead.java
│ │ │ ├── XBSchemaURL.java
│ │ │ ├── XBUpdate.java
│ │ │ ├── XBValue.java
│ │ │ ├── XBWrite.java
│ │ │ └── package-info.java
│ │ │ ├── config
│ │ │ ├── DefaultXMLFactoriesConfig.java
│ │ │ ├── XMLFactoriesConfig.java
│ │ │ └── package-info.java
│ │ │ ├── dom
│ │ │ ├── DOMAccess.java
│ │ │ └── package-info.java
│ │ │ ├── evaluation
│ │ │ ├── CanEvaluate.java
│ │ │ ├── CanEvaluateOrProject.java
│ │ │ ├── DefaultXPathEvaluator.java
│ │ │ ├── DocumentResolver.java
│ │ │ ├── InvocationContext.java
│ │ │ ├── XPathBinder.java
│ │ │ ├── XPathEvaluator.java
│ │ │ └── package-info.java
│ │ │ ├── exceptions
│ │ │ ├── XBDataNotFoundException.java
│ │ │ ├── XBDocumentParsingException.java
│ │ │ ├── XBException.java
│ │ │ ├── XBIOException.java
│ │ │ ├── XBPathException.java
│ │ │ └── package-info.java
│ │ │ ├── externalizer
│ │ │ ├── Externalizer.java
│ │ │ ├── ExternalizerAdapter.java
│ │ │ ├── PropertyFileExternalizer.java
│ │ │ └── package-info.java
│ │ │ ├── intern
│ │ │ └── DOMChangeListener.java
│ │ │ ├── io
│ │ │ ├── FileIO.java
│ │ │ ├── ProjectionIO.java
│ │ │ ├── StreamInput.java
│ │ │ ├── StreamOutput.java
│ │ │ ├── UrlIO.java
│ │ │ └── package-info.java
│ │ │ ├── package-info.java
│ │ │ ├── types
│ │ │ ├── CloseableList.java
│ │ │ ├── CloseableMap.java
│ │ │ ├── CloseableValue.java
│ │ │ ├── ConstructorConversion.java
│ │ │ ├── DefaultTypeConverter.java
│ │ │ ├── StringFactoryConversion.java
│ │ │ ├── StringRenderer.java
│ │ │ ├── TypeConverter.java
│ │ │ ├── XBAutoList.java
│ │ │ ├── XBAutoMap.java
│ │ │ ├── XBAutoValue.java
│ │ │ └── package-info.java
│ │ │ └── util
│ │ │ ├── Base64.java
│ │ │ ├── IOHelper.java
│ │ │ ├── UnionIterator.java
│ │ │ ├── intern
│ │ │ ├── DOMHelper.java
│ │ │ ├── DocScope.java
│ │ │ ├── MethodParamVariableResolver.java
│ │ │ ├── Preprocessor.java
│ │ │ ├── ReflectionHelper.java
│ │ │ ├── Scope.java
│ │ │ ├── duplex
│ │ │ │ ├── BuildDocumentVisitor.java
│ │ │ │ ├── DuplexExpression.java
│ │ │ │ ├── DuplexXPathParser.java
│ │ │ │ ├── ExpressionType.java
│ │ │ │ ├── ExpressionTypeEvaluationVisitor.java
│ │ │ │ ├── INodeEvaluationVisitor.java
│ │ │ │ ├── PostParseException.java
│ │ │ │ ├── SimpleNode.java
│ │ │ │ ├── XBPathParsingException.java
│ │ │ │ ├── XBXPathExprNotAllowedForWriting.java
│ │ │ │ └── package-info.java
│ │ │ └── package-info.java
│ │ │ └── package-info.java
│ ├── jjtree
│ │ └── xpathd.jjt
│ └── resources
│ │ └── org
│ │ └── xmlbeam
│ │ └── config
│ │ └── prettyprint.xslt
├── site
│ ├── apt
│ │ ├── .gitignore
│ │ ├── about.apt
│ │ ├── autotypes.apt
│ │ ├── download.apt
│ │ ├── evaluationapi.apt
│ │ ├── example-index.apt
│ │ ├── faq.apt
│ │ ├── formatfeature.apt
│ │ ├── index.apt
│ │ ├── introduction.apt
│ │ ├── javatypes.apt
│ │ ├── links.apt
│ │ ├── mixins.apt
│ │ ├── projectedfeature.apt
│ │ ├── projections.apt
│ │ ├── refcards.apt
│ │ ├── release-notes.apt
│ │ ├── roadmap.apt
│ │ ├── t01.apt
│ │ ├── t02.apt
│ │ ├── t03.apt
│ │ ├── t04.apt
│ │ ├── t05.apt
│ │ ├── t06.apt
│ │ ├── t07.apt
│ │ ├── t08.apt
│ │ ├── t09.apt
│ │ ├── t10.apt
│ │ ├── t11.apt
│ │ ├── t12.apt
│ │ ├── t13.apt
│ │ ├── t14.apt
│ │ ├── t15.apt
│ │ ├── t16.apt
│ │ ├── t18.apt
│ │ ├── tipsandtricks.apt
│ │ └── tutorials.apt
│ ├── resources
│ │ ├── attached-includes
│ │ │ └── css
│ │ │ │ ├── .gitignore
│ │ │ │ ├── shCoreDefault.css
│ │ │ │ └── shCoreDefault.css.gz
│ │ ├── images
│ │ │ └── about3.png
│ │ ├── robots.txt
│ │ └── sitemap.txt
│ ├── shCoreEclipse.css
│ └── site.xml
├── srcbuild
│ └── MANIFEST.MF
└── test
│ └── java
│ └── org
│ └── xmlbeam
│ ├── refcards
│ ├── EvaluationAPIRefCard.java
│ ├── FAQSnippetsTest.java
│ ├── GenerateAPIDoc.java
│ ├── SpecifyProjectorUsage.java
│ ├── XBAutoListRefCardTest.java
│ ├── XBAutoMapRefCardTest.java
│ ├── XBAutoValueRefCardTest.java
│ ├── XBProjectorReferenceCard.java
│ ├── namespaces
│ │ ├── NSDemoTest.java
│ │ ├── NameSpaceProjection.java
│ │ ├── nstest.xml
│ │ └── package-info.java
│ ├── package-info.java
│ └── xgml
│ │ ├── Section.java
│ │ └── package-info.java
│ ├── tests
│ ├── GenericXPathProjection.java
│ ├── SecurityTests.java
│ ├── TestDOMAccess.java
│ ├── TestObjectInvoker.java
│ ├── TestParameterUnwrapping.java
│ ├── TestUpdatetInvoker.java
│ ├── TestXMLProjector.java
│ ├── XMLBeamTestSuite.java
│ ├── autovalues
│ │ ├── TestAutoIntegerList.java
│ │ ├── TestAutoListOfAutoMaps.java
│ │ ├── TestAutoListOnEmptyDocuments.java
│ │ ├── TestAutoListWithSubProjections.java
│ │ ├── TestAutoMaps.java
│ │ ├── TestAutoStringList.java
│ │ ├── TestAutoSubProjectionList.java
│ │ └── TestAutoValues.java
│ ├── binding
│ │ └── TestBindAnnotation.java
│ ├── bugs
│ │ ├── TestAttributeWriteToRootDocNode.java
│ │ ├── TestBug36EmptyLinesAfterChange.java
│ │ ├── TestBug51ClassCastException.java
│ │ ├── TestBug52IntermediateElementMissing.java
│ │ ├── TestBug53NPEWhenSettingDocAsElement.java
│ │ ├── TestDataNotFoundException.java
│ │ ├── TestElementCreationWithDotInName.java
│ │ ├── TestFloatReturnsNull.java
│ │ ├── TestPOMWriteIDOnRepo.java
│ │ ├── TestStartsWithXpathFunction.java
│ │ ├── bug38
│ │ │ ├── SOAPResponse.java
│ │ │ ├── TestSoapReading.java
│ │ │ └── soap.xml
│ │ ├── bug39
│ │ │ └── NestedPathInPredicateTest.java
│ │ ├── bug54
│ │ │ ├── BaseObject.java
│ │ │ ├── SubObject.java
│ │ │ ├── XBTest.java
│ │ │ ├── package-info.java
│ │ │ └── xb.xml
│ │ ├── bug55
│ │ │ ├── SimpleTest.java
│ │ │ └── package-info.java
│ │ ├── bug58
│ │ │ ├── KfwKonditionsDokument.java
│ │ │ ├── KfwPreiskategorie.java
│ │ │ ├── Konditionen_Bank.xml
│ │ │ └── TestBug58.java
│ │ ├── bug61
│ │ │ └── TextNodeTest.java
│ │ └── bug62
│ │ │ ├── TestBug62.java
│ │ │ └── xmlwithns.xml
│ ├── concurrent
│ │ └── TestConcurrentProjectionAccess.java
│ ├── demo
│ │ ├── TestNodeContains.java
│ │ └── book.xml
│ ├── doc
│ │ ├── GraphML.java
│ │ ├── Node.java
│ │ ├── TestRailRoadDiag.java
│ │ ├── XBProjector-Sheet-compact.graphml
│ │ └── package-info.java
│ ├── evaluationapi
│ │ ├── TestEvaluationAPI.java
│ │ ├── TestSimpleCreateAPI.java
│ │ └── data.xml
│ ├── external_document.xml
│ ├── externalizer
│ │ └── TestPropertyExternalizer.java
│ ├── format
│ │ ├── ProjectionWithFormats.java
│ │ ├── TestFormatOptions.java
│ │ ├── TestProjectionWithFormats.java
│ │ └── package-info.java
│ ├── inheritance
│ │ └── TestProjectionOverriding.java
│ ├── io
│ │ ├── TestAutoFileBindings.java
│ │ └── TestIOBehavior.java
│ ├── mixins
│ │ └── TestMixins.java
│ ├── namespaces
│ │ ├── DocumentWithNamespaces.xml
│ │ ├── NamespacedProjection.java
│ │ ├── TestNamespacePhilosophies.java
│ │ └── create
│ │ │ ├── CreateDocumentWithDefaultNSFromScratchTest.java
│ │ │ ├── CreateDocumentWithNSFromScratchTest.java
│ │ │ └── package-info.java
│ ├── projectionvalidation
│ │ └── TestProjectionValidation.java
│ ├── serialization
│ │ └── TestProjectionSerialization.java
│ ├── testsuite.xml
│ ├── types
│ │ ├── TestCustomTypeConverter.java
│ │ ├── TestDefaultTypeConverter.java
│ │ └── TestStringBasedTypeConversion.java
│ ├── util
│ │ └── intern
│ │ │ ├── TestBase64Encoder.java
│ │ │ ├── TestDOMHelper.java
│ │ │ ├── TestPreprocessor.java
│ │ │ ├── TestPreprocessor2.java
│ │ │ ├── TestReflectionHelper.java
│ │ │ └── TestUnionIterator.java
│ └── xpath
│ │ ├── SetterVariants.java
│ │ ├── TestDeleterBehavior.java
│ │ ├── TestSetterVariants.java
│ │ ├── TestSetterXPathSyntax.java
│ │ ├── deletexml.xml
│ │ ├── testsetter.xml
│ │ ├── testsetter_expected.xml
│ │ └── variables
│ │ ├── TestXPathVariables.java
│ │ └── package-info.java
│ ├── testutils
│ ├── DOMDiagnoseHelper.java
│ ├── HTTPParrot.java
│ ├── JUnitHttpProxy.java
│ └── TestIOUtils.java
│ ├── tutorial
│ ├── Tutorial.java
│ ├── TutorialTestCase.java
│ ├── e01_weather
│ │ ├── TestWeatherData.java
│ │ ├── WeatherData.java
│ │ ├── WeatherData.xml
│ │ └── WeatherDataOptimized.java
│ ├── e02_jenkins
│ │ ├── JenkinsJobConfig.java
│ │ ├── TestJenkinsConfigParsing.java
│ │ ├── config.xml
│ │ └── model
│ │ │ ├── Builder.java
│ │ │ ├── ModelElement.java
│ │ │ └── Publisher.java
│ ├── e03_eclipse
│ │ ├── EclipseFormatterConfigFile.java
│ │ ├── TestEclipseCodeFormatterConfig.java
│ │ └── eclipsecodeformatprofile.xml
│ ├── e04_maven
│ │ ├── MavenPOM.java
│ │ ├── TestMavenPOM.java
│ │ └── pom.xml
│ ├── e05_rss
│ │ ├── SlashdotRSSFeed.java
│ │ └── TestFilterRSSFeed.java
│ ├── e06_xhtml
│ │ ├── TestCreationOfXHTMLDocument.java
│ │ └── XHTML.java
│ ├── e07_svg
│ │ ├── SVGDocument.java
│ │ ├── TestSVGElementSorting.java
│ │ └── svg.xml
│ ├── e08_api_mimicry
│ │ ├── Attribute.java
│ │ ├── Document.java
│ │ ├── Element.java
│ │ ├── TestDom4jMimicry.java
│ │ └── simple.xml
│ ├── e09_dreambox
│ │ ├── Dreambox.java
│ │ ├── Event.java
│ │ ├── Movie.java
│ │ └── Service.java
│ ├── e10_wikipedia
│ │ ├── ProgrammingLanguage.java
│ │ └── TestWikiAccess.java
│ ├── e11_freemind
│ │ ├── MindMap.java
│ │ ├── TestDumpMindMap.java
│ │ └── XMLBeam.mm
│ ├── e12_xml3d
│ │ ├── RunExample.java
│ │ ├── Xml3d.java
│ │ └── xml3d_template.html
│ ├── e13_graphml
│ │ ├── Edge.java
│ │ ├── EdgeTemplate.xml
│ │ ├── GraphML.java
│ │ ├── GraphMLTemplate.xml
│ │ ├── Node.java
│ │ ├── NodeTemplate.xml
│ │ └── TestGraphMLCreation.java
│ ├── e14_kml
│ │ ├── Coordinate.java
│ │ ├── CoordinateList.java
│ │ ├── KML.java
│ │ ├── TestCustomTypeConversion.java
│ │ └── polygon-simple.kml
│ ├── e15_plist
│ │ ├── PList.java
│ │ ├── TestPlistAccess.java
│ │ └── example.plist
│ ├── e16_schemaHandling
│ │ ├── TestSchemaHandling.java
│ │ ├── Vegetable.java
│ │ ├── Vegetables.java
│ │ ├── schema.xsd
│ │ └── vegetables.xml
│ ├── e17_svgTemplateInheritance
│ │ ├── ComposeSVGDocTest.java
│ │ ├── SVG.java
│ │ ├── circle_template.svg
│ │ ├── ellipse_template.svg
│ │ ├── package-info.java
│ │ ├── rect_template.svg
│ │ └── svg_document_template.svg
│ ├── e18_postalCodeRetrieval
│ │ ├── RetrievePostalCodeTest.java
│ │ └── data.xml
│ ├── e26_mondial
│ │ └── TestMondialAccess.java
│ └── e27_cdlib
│ │ ├── TestAutoCDList.java
│ │ ├── cdlib.xml
│ │ └── package-info.java
│ └── util
│ └── intern
│ └── duplex
│ ├── TestDeletionWithPredicates.java
│ ├── TestExpressionTypeDetection.java
│ ├── TestXPathParsing.java
│ └── tests.xml
└── verify_signatures.sh
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.class
2 |
3 | # Package Files #
4 | *.jar
5 | *.war
6 | *.ear
7 |
8 | target
9 | /cobertura.ser
10 | .DS_Store
11 | /hs_err_pid*.log
12 | /bin
13 | /target-eclipse
14 | /target/
15 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | xmlbeam
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.m2e.core.maven2Builder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.jdt.core.javanature
21 | org.eclipse.m2e.core.maven2Nature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding//src/main/java=UTF-8
3 | encoding//src/test/java=UTF-8
4 | encoding/=UTF-8
5 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.core.runtime.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | line.separator=\n
3 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.jdt.launching.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.launching.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE=warning
3 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | #Tue Dec 11 16:09:46 CET 2012
2 | activeProfiles=
3 | eclipse.preferences.version=1
4 | resolveWorkspaceProjects=true
5 | version=1
6 |
--------------------------------------------------------------------------------
/JUnitHttpProxy.http%3A%2F%2Fweather.service.msn.com%2Ffind.aspx%3Foutputview%3Dsearch%26weasearchstr%3DMonschau.tmp:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | XMLBeam
2 |
3 | This is a Java XML library with an extraordinary expressive API.
4 | By using XPath for read and write operations, many operations take only one line of Java code.
5 | This is how it looks:
6 |
7 | ```XML
8 |
9 |
10 | bar
11 |
12 |
13 | ```
14 |
15 | Access XML content in an object oriented way:
16 | ```Java
17 | public interface Example {
18 |
19 | // This is a getter for the attribute "type"
20 | @XBRead("/xml/example/content/@type")
21 | String getType();
22 |
23 | // This is a getter and a setter for the value of the element "content"
24 | @XBAuto("/xml/example/content")
25 | XBAutoValue content();
26 | }
27 |
28 | Example example = new XBProjector().io().file("example.xml").read(Example.class);
29 | String type = example.getType(); // "foo"
30 | String content = example.content().get(); // "bar"
31 | example.content().set("new value");
32 | ```
33 |
34 | Or, direct access via XPath enabled collection types:
35 | ```Java
36 | Map map = new XBProjector().io().file("example.xml").readAsMapOf(String.class);
37 | String type = map.get("/xml/example/content/@type");
38 | String content = map.get("/xml/example/content");
39 | map.put("/xml/example/content","new value");
40 | ```
41 |
42 | Learn more on [xmlbeam.org](https://xmlbeam.org)
43 |
--------------------------------------------------------------------------------
/logging.properties:
--------------------------------------------------------------------------------
1 | handlers= java.util.logging.ConsoleHandler
2 | .level= ALL
3 | sun.net.www.protocol.http.HttpURLConnection.level=FINEST
4 | java.util.logging.ConsoleHandler.level = ALL
5 |
6 | java.util.logging.FileHandler.pattern = %h/java%u.log
7 | java.util.logging.FileHandler.limit = 50000
8 | java.util.logging.FileHandler.count = 1
9 | java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter
10 |
11 | # Limit the message that are printed on the console to INFO and above.
12 | java.util.logging.ConsoleHandler.level = ALL
13 | java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
14 |
--------------------------------------------------------------------------------
/make_bundle.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #version=`xpath pom.xml "/project/version/text()" 2>/dev/null | tail -1`
3 | version=$1
4 | cd target
5 | for type in -javadoc.jar -sources.jar .jar .pom ; do
6 | file="xmlprojector-$version$type"
7 | allfiles="$allfiles $file $file.asc"
8 | done
9 | jar -cvf xmlbeam-$version"-bundle.jar" $allfiles
10 | cd ..
11 |
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/DefaultFileList.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam;
17 |
18 | import java.io.Closeable;
19 | import java.io.IOException;
20 |
21 | import org.w3c.dom.Node;
22 | import org.xmlbeam.evaluation.InvocationContext;
23 | import org.xmlbeam.types.CloseableList;
24 |
25 | /**
26 | * @author sven
27 | */
28 | class DefaultFileList extends AutoList implements CloseableList {
29 |
30 | private final Closeable documentWriter;
31 |
32 | /**
33 | * @param baseNode
34 | * @param invocationContext
35 | * @param documentWriter
36 | */
37 | public DefaultFileList(Node baseNode, InvocationContext invocationContext, Closeable documentWriter) {
38 | super(baseNode, invocationContext);
39 | this.documentWriter = documentWriter;
40 | }
41 |
42 | /**
43 | * @throws IOException
44 | * @see java.io.Closeable#close()
45 | */
46 | @Override
47 | public void close() throws IOException {
48 | documentWriter.close();
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/DefaultFileMap.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam;
17 |
18 | import java.io.Closeable;
19 | import java.io.IOException;
20 |
21 | import org.w3c.dom.Node;
22 | import org.xmlbeam.evaluation.InvocationContext;
23 | import org.xmlbeam.types.CloseableMap;
24 |
25 | /**
26 | * @author sven
27 | */
28 | class DefaultFileMap extends AutoMap implements CloseableMap {
29 |
30 | private final Closeable documentWriter;
31 |
32 | /**
33 | * @param baseNode
34 | * @param invocationContext
35 | * @param documentWriter
36 | * @param valueType
37 | */
38 | public DefaultFileMap(Node baseNode, InvocationContext invocationContext, Closeable documentWriter,Class> valueType) {
39 | super(baseNode, invocationContext,valueType);
40 | this.documentWriter = documentWriter;
41 | }
42 |
43 | /**
44 | * @throws IOException
45 | * @see java.io.Closeable#close()
46 | */
47 | @Override
48 | public void close() throws IOException {
49 | documentWriter.close();
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/DefaultFileValue.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam;
17 |
18 | import java.io.Closeable;
19 | import java.io.IOException;
20 |
21 | import org.w3c.dom.Node;
22 | import org.xmlbeam.evaluation.InvocationContext;
23 | import org.xmlbeam.types.CloseableValue;
24 |
25 | /**
26 | * @author sven
27 | *
28 | */
29 | class DefaultFileValue extends AutoValue implements CloseableValue {
30 |
31 | /**
32 | * Constructor.
33 | * @param baseNode
34 | * @param invocationContext
35 | * @param documentWriter
36 | */
37 | public DefaultFileValue(Node baseNode, InvocationContext invocationContext,Closeable documentWriter) {
38 | super(baseNode, invocationContext);
39 | this.documentWriter=documentWriter;
40 | }
41 |
42 |
43 | private final Closeable documentWriter;
44 |
45 |
46 | /**
47 | * @throws IOException
48 | * @see java.io.Closeable#close()
49 | */
50 | @Override
51 | public void close() throws IOException {
52 | documentWriter.close();
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/DomChangeTracker.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam;
17 |
18 | import javax.xml.xpath.XPathExpressionException;
19 |
20 | import org.xmlbeam.exceptions.XBException;
21 | import org.xmlbeam.intern.DOMChangeListener;
22 |
23 | /**
24 | *
25 | */
26 | abstract class DomChangeTracker implements DOMChangeListener {
27 |
28 | private boolean needRefresh = true;
29 |
30 | @Override
31 | public void domChanged() {
32 | needRefresh = true;
33 | }
34 |
35 | void refreshForReadIfNeeded() {
36 | if (needRefresh) {
37 | invokeRefresh(false);
38 | }
39 | }
40 |
41 | abstract void refresh(boolean b) throws XPathExpressionException;
42 |
43 | void refreshForWriteIfNeeded() {
44 | if (needRefresh) {
45 | invokeRefresh(true);
46 | }
47 | }
48 |
49 | private void invokeRefresh(boolean b) {
50 | try {
51 | refresh(b);
52 | needRefresh = false;
53 | } catch (XPathExpressionException e) {
54 | needRefresh = true;
55 | throw new XBException("Unexpected error during evaluation.", e);
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/annotation/XBAuto.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.annotation;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 | import java.lang.annotation.Target;
22 |
23 | /**
24 | * Define a projection function to bind elements to XBAutoValue or XBAutoList.
25 | *
26 | * @author Sven Ewald
27 | */
28 | @Retention(RetentionPolicy.RUNTIME)
29 | @Target(ElementType.METHOD)
30 | public @interface XBAuto {
31 | /**
32 | * XPath to select element or attribute to be bind.
33 | *
34 | * @return XPath expression. (Can be omitted if your
35 | * {@link org.xmlbeam.externalizer.Externalizer} implementation provides a path.)
36 | */
37 | String value() default "";
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/annotation/XBDelete.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.annotation;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 | import java.lang.annotation.Target;
22 |
23 | /**
24 | * Define a projection function to delete elements or attributes.
25 | *
26 | * @author Sven Ewald
27 | */
28 | @Retention(RetentionPolicy.RUNTIME)
29 | @Target(ElementType.METHOD)
30 | public @interface XBDelete {
31 |
32 | /**
33 | * XPath expression to select XML nodes to be deleted.
34 | *
35 | * @return XPath expression. (Can be omitted if your
36 | * {@link org.xmlbeam.externalizer.Externalizer} implementation provides a path.)
37 | */
38 | String value() default "";
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/annotation/XBDocURL.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.annotation;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Inherited;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | /**
25 | * Bind the decorated projection to a XML document location. When used on methods, an implicit
26 | * projection is created every time the method is invoked.
27 | *
28 | * @author Sven Ewald
29 | */
30 | @Retention(RetentionPolicy.RUNTIME)
31 | @Target({ ElementType.METHOD, ElementType.TYPE })
32 | @Inherited
33 | public @interface XBDocURL {
34 |
35 | /**
36 | * A URL where the document is located.
37 | * @return value.
38 | */
39 | String value();
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/annotation/XBOverride.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.annotation;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 | import java.lang.annotation.Target;
22 |
23 | /**
24 | * Needed for overriding Object methods with default methods.
25 | *
26 | * @author Sven Ewald
27 | */
28 | @Retention(RetentionPolicy.RUNTIME)
29 | @Target(ElementType.METHOD)
30 | public @interface XBOverride {
31 |
32 | /**
33 | * Use this on a default method with the name of the method to be overridden. Make sure your
34 | * default method has the same return type and same parameters as the method with given name.
35 | *
36 | * @return name of method to be overridden. Must be one of the methods in the type Object.
37 | */
38 | String value();
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/annotation/XBRead.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.annotation;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 | import java.lang.annotation.Target;
22 |
23 | /**
24 | * Define a projection function to read elements of a projection.
25 | *
26 | * @author Sven Ewald
27 | */
28 | @Retention(RetentionPolicy.RUNTIME)
29 | @Target(ElementType.METHOD)
30 | public @interface XBRead {
31 |
32 | /**
33 | * XPath to select element or attribute to be read.
34 | *
35 | * @return XPath expression. (Can be omitted if your
36 | * {@link org.xmlbeam.externalizer.Externalizer} implementation provides a path.)
37 | */
38 | String value() default "";
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/annotation/XBSchemaURL.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.annotation;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Inherited;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | /**
25 | * Declare a schema URL to a projection interface. Not used during runtime, but useful for 3rd party
26 | * tools to validate projection interfaces.
27 | *
28 | * @author Sven Ewald
29 | */
30 | @Retention(RetentionPolicy.SOURCE)
31 | @Target({ ElementType.METHOD, ElementType.TYPE })
32 | @Inherited
33 | public @interface XBSchemaURL {
34 |
35 | /**
36 | * A URL where the schema is located.
37 | *
38 | * @return value.
39 | */
40 | String value();
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/annotation/XBUpdate.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.annotation;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 | import java.lang.annotation.Target;
22 |
23 | /**
24 | * Define a projection function to update values of existing attributes or elements.
25 | *
26 | * @author Sven Ewald
27 | */
28 | @Retention(RetentionPolicy.RUNTIME)
29 | @Target(ElementType.METHOD)
30 | public @interface XBUpdate {
31 |
32 | /**
33 | * XPath to select element or attribute to be updated.
34 | *
35 | * @return XPath expression. (Can be omitted if your
36 | * {@link org.xmlbeam.externalizer.Externalizer} implementation provides a path.)
37 | */
38 | String value() default "";
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/annotation/XBValue.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.annotation;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 | import java.lang.annotation.Target;
22 |
23 | /**
24 | * Marks a parameter in the setter as the value to be set. Other parameters are allowed and will be
25 | * replace present place holders in the XPath expression. If no parameter is annotated, the first
26 | * one will be taken.
27 | *
28 | * @author Sven Ewald
29 | */
30 | @Retention(RetentionPolicy.RUNTIME)
31 | @Target(ElementType.PARAMETER)
32 | public @interface XBValue {
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/annotation/XBWrite.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.annotation;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 | import java.lang.annotation.Target;
22 |
23 | /**
24 | * Define a writeable projection function for elements of a projection.
25 | *
26 | * @author Sven Ewald
27 | */
28 | @Retention(RetentionPolicy.RUNTIME)
29 | @Target(ElementType.METHOD)
30 | public @interface XBWrite {
31 |
32 | /**
33 | * XPath expression to project XML data to return type of decorated method.
34 | *
35 | * @return XPath expression. (Can be omitted if your
36 | * {@link org.xmlbeam.externalizer.Externalizer} implementation provides a path.)
37 | */
38 | String value() default "";
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/annotation/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * Use the annotations in this package to declare your projection interfaces.
18 | * Projections may read, write or delete parts of the document.
19 | * See annotations {@link org.xmlbeam.annotation.XBRead},
20 | * {@link org.xmlbeam.annotation.XBWrite} and {@link org.xmlbeam.annotation.XBDelete}.
21 | */
22 | package org.xmlbeam.annotation;
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/config/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * Contains the {@link org.xmlbeam.config.XMLFactoriesConfig} interface and it's default implementation.
18 | * You need this if you wand to plug in another XML parser or XPath engine.
19 | */
20 | package org.xmlbeam.config;
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/dom/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * Use the interfaces and classes in this package to get access to the DOM behind
18 | * a projection.
19 | *
20 | */
21 | package org.xmlbeam.dom;
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/evaluation/CanEvaluate.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.evaluation;
17 |
18 | import org.xmlbeam.util.intern.DocScope;
19 | import org.xmlbeam.util.intern.Scope;
20 |
21 | /**
22 | * @author sven
23 | */
24 | public interface CanEvaluate {
25 |
26 | /**
27 | * @param xpath
28 | * to be evaluated on input
29 | * @return EvaluationBuilder to choose target type
30 | */
31 | @Scope(DocScope.IO)
32 | XPathEvaluator evalXPath(String xpath);
33 |
34 | }
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/evaluation/CanEvaluateOrProject.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.evaluation;
17 |
18 | import org.xmlbeam.types.XBAutoMap;
19 | import org.xmlbeam.util.intern.DocScope;
20 | import org.xmlbeam.util.intern.Scope;
21 |
22 | /**
23 | * @author sven
24 | */
25 | public interface CanEvaluateOrProject extends CanEvaluate {
26 |
27 | /**
28 | * @param type
29 | * @return a projection
30 | */
31 | @Scope(DocScope.IO)
32 | T createProjection(Class type);
33 |
34 | /**
35 | * @param class1
36 | * @return a map bound to the XML document element
37 | */
38 | @Scope(DocScope.IO)
39 | XBAutoMap createMapOf(Class class1);
40 | }
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/evaluation/DocumentResolver.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.evaluation;
17 |
18 | import java.io.IOException;
19 |
20 | import org.w3c.dom.Document;
21 |
22 | /**
23 | * @author sven
24 | */
25 | public interface DocumentResolver {
26 |
27 | /**
28 | * Resolve document, possibly using the given class.
29 | *
30 | * @param resourceAwareClasses
31 | * may provide a class loader, may be null.
32 | * @return a dom Document
33 | * @throws IOException
34 | */
35 | Document resolve(Class>... resourceAwareClasses) throws IOException;
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/evaluation/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * Package for classes and interfaces related to the direct evaluation API.
18 | * With this API you may omit declaring projection interfaces.
19 | * @author sven
20 | */
21 | package org.xmlbeam.evaluation;
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/exceptions/XBDataNotFoundException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.exceptions;
17 |
18 | /**
19 | * You may declare your reading projection methods throwing exceptions.
20 | * This would be a good candidate, especially for debugging purpose.
21 | * If declare any other exception, this one will be set as the cause.
22 | */
23 | final public class XBDataNotFoundException extends XBException {
24 |
25 | private static final long serialVersionUID = -4993020872096092774L;
26 | private final String resolvedXPath;
27 |
28 | /**
29 | * @param xpath resolved XPath.
30 | */
31 | public XBDataNotFoundException(String xpath) {
32 | super("Data that was expected to be found... was not");
33 | this.resolvedXPath=xpath;
34 | }
35 |
36 | /**
37 | * @return The XPath after pre-processing that did not select any data.
38 | */
39 | public String getResolvedXPath() {
40 | return resolvedXPath;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/exceptions/XBDocumentParsingException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.exceptions;
17 |
18 | /**
19 | * This exception wraps all parsing error exceptions thrown by the underlying xml parser.
20 | */
21 | public class XBDocumentParsingException extends XBException {
22 |
23 | /**
24 | *
25 | */
26 | private static final long serialVersionUID = 6813222667046360309L;
27 |
28 | /**
29 | * @param msg Error message
30 | * @param e Cause
31 | */
32 | public XBDocumentParsingException(String msg, Throwable e) {
33 | super(msg, e);
34 | }
35 |
36 | /**
37 | * @param e Cause
38 | */
39 | public XBDocumentParsingException(Throwable e) {
40 | super("Error during XML parsing", e);
41 | }
42 |
43 |
44 |
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/exceptions/XBException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.exceptions;
17 |
18 | /**
19 | * XMLBeam root exception. The base of all exceptions thrown during invoking projection methods.
20 | * Needs to be a RuntimeException to avoid declaring exceptions on each projection method.
21 | */
22 | public class XBException extends RuntimeException {
23 |
24 | private static final long serialVersionUID = 4989019505068594914L;
25 |
26 | /**
27 | * Exception constructor.
28 | *
29 | * @param msg
30 | * @param e
31 | */
32 | public XBException(final String msg, final Throwable e) {
33 | super(msg, e);
34 | }
35 |
36 | /**
37 | * Exception constructor.
38 | *
39 | * @param msg
40 | */
41 | public XBException(final CharSequence msg) {
42 | super(msg.toString());
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/exceptions/XBIOException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.exceptions;
17 |
18 | import java.io.IOException;
19 |
20 | /**
21 | * Wraper for IOException.
22 | *
23 | */
24 | public class XBIOException extends XBException {
25 |
26 | /**
27 | *
28 | */
29 | private static final long serialVersionUID = -4098241369287487356L;
30 |
31 | /**
32 | * @param e
33 | */
34 | public XBIOException(IOException e) {
35 | super("IO Error:"+e.getMessage(), e);
36 | }
37 |
38 | /**
39 | * @param msg
40 | * @param e
41 | */
42 | public XBIOException(String msg, IOException e) {
43 | super(msg,e);
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/exceptions/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * @author se
18 | *
19 | */
20 | package org.xmlbeam.exceptions;
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/externalizer/ExternalizerAdapter.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.externalizer;
17 |
18 | import java.lang.reflect.Method;
19 |
20 | /**
21 | * This default implementation for the {@link Externalizer} interface is just a shortcut
22 | * if you only want to implement one of the interfaces methods. Feel free to extend
23 | * this class and implement your own logic.
24 | *
25 | */
26 | public class ExternalizerAdapter implements Externalizer {
27 |
28 | private static final long serialVersionUID = 352472023631762615L;
29 |
30 | /**
31 | * {@inheritDoc}
32 | */
33 | @Override
34 | public String resolveXPath(String annotationValue, Method method, Object[] args) {
35 | return annotationValue;
36 | }
37 |
38 | /**
39 | * {@inheritDoc}
40 | */
41 | @Override
42 | public String resolveURL(String annotationValue, Method method, Object[] args) {
43 | return annotationValue;
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/externalizer/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * Package containing the {@link org.xmlbeam.externalizer.Externalizer} interface.
18 | * You need it if you want to store the XPath expressions outside of the Java code.
19 | * There is even an example implementation {@link org.xmlbeam.externalizer.PropertyFileExternalizer}.
20 | */
21 | package org.xmlbeam.externalizer;
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/intern/DOMChangeListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.intern;
17 |
18 | /**
19 | *
20 | */
21 | public interface DOMChangeListener {
22 |
23 | /**
24 | *
25 | */
26 | void domChanged();
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/io/StreamOutput.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.io;
17 |
18 | import java.io.OutputStream;
19 |
20 | import javax.xml.transform.TransformerException;
21 | import javax.xml.transform.dom.DOMSource;
22 | import javax.xml.transform.stream.StreamResult;
23 |
24 | import org.xmlbeam.XBProjector;
25 | import org.xmlbeam.dom.DOMAccess;
26 | import org.xmlbeam.exceptions.XBException;
27 | import org.xmlbeam.util.intern.DocScope;
28 | import org.xmlbeam.util.intern.Scope;
29 |
30 | /**
31 | * @author Sven Ewald
32 | */
33 | public class StreamOutput {
34 |
35 | private final XBProjector projector;
36 | private final OutputStream os;
37 |
38 | /**
39 | * @param xmlProjector
40 | * @param os
41 | */
42 | public StreamOutput(final XBProjector xmlProjector, final OutputStream os) {
43 | this.projector = xmlProjector;
44 | this.os = os;
45 | }
46 |
47 | /**
48 | * @param projection
49 | */
50 | @Scope(DocScope.IO)
51 | public void write(final Object projection) {
52 | try {
53 | projector.config().createTransformer().transform(new DOMSource(((DOMAccess) projection).getDOMNode()), new StreamResult(os));
54 | } catch (TransformerException e) {
55 | throw new XBException("Error during writing document",e);
56 | }
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/io/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * Classes used to read and write projections.
18 | */
19 | package org.xmlbeam.io;
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * This package contains the {@link org.xmlbeam.XBProjector} which is the starting point of using XMLBeam.
18 | *
19 | */
20 | package org.xmlbeam;
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/types/CloseableList.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.types;
17 |
18 | import java.io.Closeable;
19 | import java.util.List;
20 |
21 | /**
22 | * Instances of this interface will change the DOM just like an XBAutoList,
23 | * but persist the changes when close() is invoked.
24 | * @param component type
25 | */
26 | public interface CloseableList extends List, Closeable {
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/types/CloseableMap.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.types;
17 |
18 | import java.io.Closeable;
19 | import java.util.Map;
20 |
21 | /**
22 | * Instances of this interface will change the DOM just like an XBAutoMap,
23 | * but persist the changes when close() is invoked.
24 | * @param component type
25 | */
26 | public interface CloseableMap extends Map, Closeable {
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/types/CloseableValue.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.types;
17 |
18 | import java.io.Closeable;
19 |
20 | /**
21 | * Instances of this interface will change the DOM just like an XBAutoValue, but persist the changes
22 | * when close() is invoked.
23 | *
24 | * @author sven
25 | * @param Component type
26 | */
27 | public interface CloseableValue extends XBAutoValue, Closeable {
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/types/StringRenderer.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 Sven Ewald
3 | *
4 | * This file is part of JSONBeam.
5 | *
6 | * JSONBeam is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, any
9 | * later version.
10 | *
11 | * JSONBeam is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with JSONBeam. If not, see .
18 | */
19 | package org.xmlbeam.types;
20 |
21 | import java.io.Serializable;
22 |
23 | /**
24 | * A StringRenderer is used to render values in XML. Optionally a pattern may be used. Default is
25 | * calling toString().
26 | *
27 | * @author sven
28 | */
29 | public interface StringRenderer extends Serializable {
30 | /**
31 | * @param dataType
32 | * @param data
33 | * @param optionalFormatPattern
34 | * @return a string representation of the input data.
35 | */
36 | String render(Class extends T> dataType, T data, String... optionalFormatPattern);
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/types/TypeConverter.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.types;
17 |
18 | import java.io.Serializable;
19 |
20 | /**
21 | * @author Sven Ewald
22 | */
23 | public interface TypeConverter extends Serializable {
24 |
25 | /**
26 | * Check if this converter can convert Strings to the given target type.
27 | *
28 | * @param targetType
29 | * @return true if conversion is possible.
30 | */
31 | boolean isConvertable(Class targetType);
32 |
33 | /**
34 | * Convert a String value to the given target type. There is no parameter check. Caller
35 | * must check by calling {@code isConvertable(...)} before.
36 | *
37 | * @param targetType
38 | * @param data
39 | * @param optionalFormatPattern
40 | * @return a new instance of the target type.
41 | */
42 | T convertTo(Class targetType, String data, String... optionalFormatPattern);
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/types/XBAutoList.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.types;
17 |
18 | import java.util.List;
19 |
20 | import org.xmlbeam.annotation.XBAuto;
21 |
22 |
23 | /**
24 | * A List implementation that automatically changes the DOM when instances of this type are changed.
25 | * It can be used by declaring a reading projection method returning this type.
26 | * If the XBAuto annotation is used, returning List instances will implement this interface.
27 | * @see XBAutoValue
28 | * @see XBAuto
29 | * @author sven
30 | * @param Component type of this collection
31 | */
32 | public interface XBAutoList extends List {
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/types/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * Classes and interfaces to control type conversion.
18 | */
19 | package org.xmlbeam.types;
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/util/intern/DocScope.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2017 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.util.intern;
17 |
18 | /**
19 | *
20 | */
21 | public enum DocScope {
22 | IO, CONFIG, INPUT, OUTPUT
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/util/intern/Scope.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2017 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.util.intern;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 | import java.lang.annotation.Target;
22 |
23 | /**
24 | *
25 | */
26 | @Retention(RetentionPolicy.RUNTIME)
27 | @Target(ElementType.METHOD)
28 | public @interface Scope {
29 | DocScope value();
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/util/intern/duplex/DuplexXPathParser.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.util.intern.duplex;
17 |
18 | import java.util.Map;
19 |
20 | import java.io.StringReader;
21 |
22 | import org.xmlbeam.exceptions.XBException;
23 |
24 | /**
25 | * @author sven
26 | */
27 | public class DuplexXPathParser {
28 |
29 | private final Map userDefinedMapping;
30 |
31 | /**
32 | * @param path
33 | * @return DuplexExpression
34 | * @throws XBPathParsingException
35 | */
36 | public DuplexExpression compile(final CharSequence path) throws XBPathParsingException {
37 | final XParser parser = new XParser(new StringReader(path.toString()));
38 | try {
39 | SimpleNode node = parser.START();
40 | return new DuplexExpression(node, path, userDefinedMapping);
41 | } catch (ParseException e) {
42 | throw new XBException("Can not parse xpath:'" + path + "'", e);
43 | }
44 | }
45 |
46 | /**
47 | * @param userDefinedMapping
48 | */
49 | public DuplexXPathParser(final Map userDefinedMapping) {
50 | this.userDefinedMapping = userDefinedMapping;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/util/intern/duplex/ExpressionType.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.util.intern.duplex;
17 |
18 | /**
19 | * Enum for xpath expression types.
20 | *
21 | * @author sven
22 | */
23 | public enum ExpressionType {
24 | /**
25 | * Expression selects a node.
26 | */
27 | NODE(false),
28 | /**
29 | * Expression selects an element.
30 | */
31 | ELEMENT(false),
32 | /**
33 | * Expression selects an attribute.
34 | */
35 | ATTRIBUTE(false),
36 | /**
37 | * Expression returns a value.
38 | */
39 | VALUE(true);
40 |
41 | private ExpressionType(final boolean mustEvaluateAsString) {
42 | this.mustEvaluateAsString = mustEvaluateAsString;
43 | }
44 |
45 | private final boolean mustEvaluateAsString;
46 |
47 | /**
48 | * Some expressions can not be evaluated as node or node lists. (e.g. functions) These must be
49 | * evaluated as Strings.
50 | *
51 | * @return true for values
52 | */
53 | public boolean isMustEvalAsString() {
54 | return mustEvaluateAsString;
55 | };
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/util/intern/duplex/INodeEvaluationVisitor.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 Sven Ewald
3 | *
4 | * This file is part of JSONBeam.
5 | *
6 | * JSONBeam is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, any
9 | * later version.
10 | *
11 | * JSONBeam is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with JSONBeam. If not, see .
18 | */
19 | package org.xmlbeam.util.intern.duplex;
20 |
21 | import org.xmlbeam.util.intern.duplex.XParserVisitor;
22 |
23 | interface INodeEvaluationVisitor extends XParserVisitor {
24 |
25 | interface VisitorClosure {
26 | void apply(SimpleNode node, org.w3c.dom.Node data);;
27 | }
28 |
29 | @Override
30 | public R visit(SimpleNode node, org.w3c.dom.Node data);
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/util/intern/duplex/XBPathParsingException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.util.intern.duplex;
17 |
18 | import org.xmlbeam.exceptions.XBException;
19 |
20 | /**
21 | * @author sven
22 | */
23 | public class XBPathParsingException extends XBException {
24 |
25 | private static final long serialVersionUID = -4923686442969043087L;
26 |
27 | /** TODO:Refactor to absolute begin and end
28 | * @param string
29 | * @param beginLine
30 | * @param beginColumn
31 | * @param endColumn
32 | * @param endLine
33 | */
34 | public XBPathParsingException(final String string, final int beginLine, final int beginColumn, final int endColumn, final int endLine) {
35 | super(string + " in line " + beginLine + " col " + beginColumn + " to " + endColumn, null);
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/util/intern/duplex/XBXPathExprNotAllowedForWriting.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.util.intern.duplex;
17 |
18 | /**
19 | * Exception for the case that a xpath was declared in @XBWrite that is not allowed for writing.
20 | */
21 | public class XBXPathExprNotAllowedForWriting extends XBPathParsingException { // NO_UCD (use default)
22 |
23 | private static final long serialVersionUID = 8944815612805655746L;
24 |
25 | /**
26 | * Constructor.
27 | *
28 | * @param node
29 | * @param reason
30 | */
31 | public XBXPathExprNotAllowedForWriting(final SimpleNode node, final String reason) { // NO_UCD (use default)
32 | super(reason + ": Node " + node.toString() + " is not supported for writing expressions", node.beginLine, node.beginColumn, node.endColumn, node.endLine);
33 | //node.parser.token_source.input_stream.inputStream.reset().
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/util/intern/duplex/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * Internal package for the bidirectional XPath parser.
18 | * Do not use this package.
19 | */
20 | package org.xmlbeam.util.intern.duplex;
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/util/intern/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * Internal package with classes that will change in minor version updates.
18 | * Do not use this package.
19 | */
20 | package org.xmlbeam.util.intern;
--------------------------------------------------------------------------------
/src/main/java/org/xmlbeam/util/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * You may like to use the {@link org.xmlbeam.util.IOHelper} class to add basic HTTP authentication.
18 | */
19 | package org.xmlbeam.util;
--------------------------------------------------------------------------------
/src/main/resources/org/xmlbeam/config/prettyprint.xslt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/site/apt/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SvenEwald/xmlbeam/84a2a91c216622c611a948d88792c846b532aa0a/src/site/apt/.gitignore
--------------------------------------------------------------------------------
/src/site/apt/about.apt:
--------------------------------------------------------------------------------
1 | About
2 |
3 | * Developer
4 |
5 | XMLBeam is developed by {{{https://github.com/SvenEwald}Sven Ewald}} with contributions by {{{https://github.com/cemonds}Christoph Emonds}}.
6 |
7 | * Special thanks to
8 |
9 | * {{{https://github.com/olivergierke}Oliver Gierke}} for feature requests and bug reports.
10 |
11 | * {{{https://github.com/neilmcguigan}Neil McGuigan}} for feature requests and bug reports.
12 |
13 | * {{{https://plus.google.com/101312240852175091441/}Micha Kops}} for his {{{http://www.hascode.com/2014/07/xmlbeam-snippets-and-examples/}tutorial}}.
14 |
15 | * {{{https://github.com/ghajba}Gábor László Hajba}} for his {{{https://hahamo.wordpress.com/tag/xmlbeam/}articles on XMLBeam}}.
16 |
17 | * Bug Tracking
18 |
19 | Feel free to use the {{{https://github.com/SvenEwald/xmlbeam/issues}bugtracker}}.
20 |
21 | * License
22 |
23 | Licensed under the Apache License, Version 2.0 (the "License");
24 |
25 | you may not use this file except in compliance with the License.
26 | You may obtain a copy of the License at
27 |
28 | http://www.apache.org/licenses/LICENSE-2.0
29 |
30 | Unless required by applicable law or agreed to in writing, software
31 | distributed under the License is distributed on an "AS IS" BASIS,
32 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
33 | See the License for the specific language governing permissions and
34 | limitations under the License.
35 |
36 | * Contact
37 |
38 | Please use contact_03@xmlbeam.org as the current contact address. (The number will increase when the amount of spam rises ;)
39 |
40 | * Support
41 |
42 | * Best support for this project is trying it out, having fun with it, reporting bugs, and spreading the word.
43 |
--------------------------------------------------------------------------------
/src/site/apt/download.apt:
--------------------------------------------------------------------------------
1 | Download
2 |
3 | XMLBeam is available as Maven dependency via central repository or as direct jar download.
4 |
5 | * Maven
6 |
7 | Just add the following to your pom.xml:
8 |
9 | ----------------------------------------
10 |
11 | org.xmlbeam
12 | xmlprojector
13 | x.x.x
14 |
15 | ----------------------------------------
16 |
17 | * Direct jar download from central repository:
18 |
19 | {{{http://search.maven.org/remotecontent?filepath=org/xmlbeam/xmlprojector/x.x.x/xmlprojector-x.x.x.jar}xmlprojector-x.x.x.jar}}
20 |
21 | {{{http://search.maven.org/remotecontent?filepath=org/xmlbeam/xmlprojector/x.x.x/xmlprojector-x.x.x-javadoc.jar}xmlprojector-x.x.x-javadoc.jar}}
22 |
23 | {{{http://search.maven.org/remotecontent?filepath=org/xmlbeam/xmlprojector/x.x.x/xmlprojector-x.x.x-sources.jar}xmlprojector-x.x.x-sources.jar}}
24 |
--------------------------------------------------------------------------------
/src/site/apt/evaluationapi.apt:
--------------------------------------------------------------------------------
1 |
2 | Evaluation API
3 |
4 | The most common use of XMLBeam is via defining projection interfaces and using the projector.io()... mehtods to read and write these projections.
5 | For some use cases you don't need a projection interface at all:
6 |
7 | %{include|charset=UTF-8|highlight-theme=eclipse|show-gutter=false|snippet=#EvaluationAPIRefCardExample|source=src/test/java/org/xmlbeam/refcards/EvaluationAPIRefCard.java}
8 |
9 | but you can mix the projection and evaluation API seamlessly:
10 |
11 | %{include|charset=UTF-8|highlight-theme=eclipse|show-gutter=false|snippet=#EvaluationAPIRefCardExample2|source=src/test/java/org/xmlbeam/refcards/EvaluationAPIRefCard.java}
12 |
13 | %{include|charset=UTF-8|highlight-theme=eclipse|show-gutter=false|snippet=#EvaluationAPIRefCardExample3|source=src/test/java/org/xmlbeam/refcards/EvaluationAPIRefCard.java}
14 |
--------------------------------------------------------------------------------
/src/site/apt/example-index.apt:
--------------------------------------------------------------------------------
1 | ------
2 | Example Index
3 | ------
4 | Sven Ewald
5 | ------
6 | 2014
7 | ------
8 |
9 | Exampls by Subject
10 |
11 | * Creating a Subprojection
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/site/apt/introduction.apt:
--------------------------------------------------------------------------------
1 | About
2 |
3 | This is a Java XML library and a very flexible alternative to data binding.
4 | It works by creating "views" on parts of a XML DOM tree into Java objects and back.
5 | These views can be either user defined interfaces, called "projections", or predefined collection types (called auto values).
6 |
7 | Motivation
8 |
9 | What's wrong with Java XML data binding?
10 |
11 | Data binding needs the structure of XML documents being mirrored to Java object structures.
12 | That means your Java API is determined by XML.
13 | XMLBeam helps to avoid API changes by utilizing a mapping layer of XPath expressions.
14 | Don't worry, you won't need a deep knowledge of XPath.
15 |
16 | Usage
17 |
18 | The basic philosophy behind XMLBeam is to use XPath to project parts of a DOM to a Java type.
19 | These types can be {{{./autotypes.html}special collection types}} or {{{./projections.html}user defined interfaces}}.
20 | Of course, both ways can be combined.
21 | Projection methods can return auto types and auto types can work with projection interfaces.
22 |
--------------------------------------------------------------------------------
/src/site/apt/javatypes.apt:
--------------------------------------------------------------------------------
1 | Supported Java Types
2 |
3 | XMLBeam supports reading and writing XML with the following Java types:
4 |
5 | * Primitives
6 |
7 | All primitive types (bool, short, int, long, float, double) are supported.
8 | If a default value is needed, 0 and false are used.
9 |
10 | * Autoboxing types
11 | Boolean, Short, Integer, Long, Float and Double are supported.
12 | Null indicates nonexisting values.
13 |
14 | * String
15 |
16 | * Date
17 |
18 | * Any type with a String constructor
19 | You can directly map XML values to your own classes by providing a construtor with a String parameter.
20 | Alternatively you can provide a factory method.
21 |
22 | * Collection Types
23 |
24 | Collections and Optionals of any of these types are supported.
25 |
26 | * List
27 |
28 | * Stream
29 |
30 | * Optional
31 |
32 |
--------------------------------------------------------------------------------
/src/site/apt/links.apt:
--------------------------------------------------------------------------------
1 | External references & articles
2 |
3 | * XML processing and website scraping in Java
4 |
5 | * How to use JSoup and XMLBeam in practice. EBook by Gabor Laszlo Hajba. {{{http://leanpub.com/javaxml}Buy it here.}}
6 |
7 | * JAXEnter (English)
8 |
9 | * {{http://jaxenter.com/a-new-approach-to-xml-part-1-data-projection-with-xmlbeam-107572.html}}
10 |
11 | * {{http://jaxenter.com/a-new-approach-to-xml-part-2-features-of-the-xmlbeam-library-107614.html}}
12 |
13 | * {{http://jaxenter.com/a-new-approach-to-xml-part-3-seamless-usage-of-namespaces-and-easy-projector-setup-107661.html}}
14 |
15 | * {{http://jaxenter.com/a-new-approach-to-xml-part-4-a-template-pattern-to-create-xml-documents-107733.html}}
16 |
17 |
18 | * JAXEnter (German)
19 |
20 | * {{http://jaxenter.de/artikel/Ein-neuer-Blick-auf-XML-171331}}
21 |
22 | * {{http://jaxenter.de/artikel/Ein-neuer-Blick-auf-XML-Teil-2-171669}}
23 |
24 | * {{http://jaxenter.de/artikel/Ein-neuer-Blick-auf-XML-Teil-3-172035}}
25 |
26 | * {{http://jaxenter.de/artikel/Ein-neuer-Blick-auf-XML-XMLBeam-Teil-4-172476}}
27 |
28 |
29 | * hasCode.com (English)
30 |
31 | * {{http://www.hascode.com/2014/07/xmlbeam-snippets-and-examples}}
32 |
33 |
34 | * hahamo (English)
35 |
36 | * {{https://hahamo.wordpress.com/2014/09/16/xml-processing-advanced}}
37 |
38 | * {{https://hahamo.wordpress.com/2014/09/23/website-scraping-with-jsoup-and-xmlbeam-part-1}}
39 |
40 | * {{https://hahamo.wordpress.com/2014/09/30/website-scraping-with-jsoup-and-xmlbeam-part-2}}
41 |
42 | * {{https://hahamo.wordpress.com/2014/10/07/website-scraping-with-jsoup-and-xmlbeam-part-3}}
43 |
44 |
--------------------------------------------------------------------------------
/src/site/apt/mixins.apt:
--------------------------------------------------------------------------------
1 | What are mixins and how does it work?
2 |
3 | Mixins are a pre Java8 feature. If you are using JDK8, this feature is obsolete.
4 | Projections are dynamic proxy instances for the projection interfaces.
5 | Therefore it is not possible to add additional method implementations by simply extending them.
6 | There would be no way to get working instances. All instances have to be created by a projector.
7 |
8 | * First approach: Delegator pattern (not recommended)
9 |
10 | You may create delegating instances of the projection interfaces.
11 | Implement your methods and delegate the projection methods to a projection obtained from a projector.
12 |
13 | []
14 |
15 | This works and is quite straightforward but has some drawbacks:
16 |
17 | * You would have to ensure that each instance of a projection will be wrapped in your delegator.
18 | This might be even more inconvenient when retaining collections of sub projections.
19 |
20 | * You are writing glue code between your domain objects and the projections.
21 | XMLBeam is all about avoiding glue code.
22 |
23 | * Second approach: Mixins (use this)
24 |
25 | Define a mixin interface with the methods you like to add to add to a projection and let your mixin class implement this interface.
26 | Instead of extending the projection interface, you let the projection interface extend your mixin interface.
27 | Therefore your methods are "mixed into" your projection interface.
28 | Then register the mixin in the projector to be used as implementation for your projection interface.
--------------------------------------------------------------------------------
/src/site/apt/projectedfeature.apt:
--------------------------------------------------------------------------------
1 |
2 | Projected Data
3 |
4 | There are two special types allowing bidirectional projections to values and lists.
5 |
6 | %{toc|section=1|fromDepth=2|toDepth=2}
7 |
8 | * Projected
9 |
10 |
11 |
12 | * ProjectedList
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/site/apt/projections.apt:
--------------------------------------------------------------------------------
1 | Projections:
2 |
3 | Projections are "views" into the XML DOM tree.
4 | They are defined by combining an user defined interface with XPath expressions.
5 | XPath is used to locate the data in the DOM, the Java return types are used for type conversion.
6 |
7 | ----------------------------------------
8 |
9 |
10 | bar
11 |
12 |
13 | ----------------------------------------
14 |
15 | Access XML content in an object oriented way:
16 |
17 | ----------------------------------------
18 | public interface Example {
19 |
20 | @XBRead("/xml/example/content")
21 | String getContent();
22 |
23 | @XBRead("/xml/example/content/@type")
24 | String getType();
25 | }
26 | ----------------------------------------
27 |
28 | See {{{./refcards.html#Annotations} Annotations}} for more.
29 |
30 |
--------------------------------------------------------------------------------
/src/site/apt/t01.apt:
--------------------------------------------------------------------------------
1 | Tutorial 1
2 |
3 | *E01: Printing some weather data
4 |
5 | %{include|source-content-type=apt|snippet=#TutorialDescription|source=src/test/java/org/xmlbeam/tutorial/e01_weather/TestWeatherData.java}}
6 |
7 |
8 | ** XML Content
9 |
10 | Using the MSN weather service will get you some XML content similar to this:
11 |
12 | ---------
13 |
14 |
20 |
21 |
22 |
23 | ---------
24 | We see that the XML structure consists of three elements and number of attributes holding the data.
25 | If you execute the tutorial example code you will see that there are even more attributes that are shortened out for readability.
26 | If you would use a data binding XML library to access this data you would get three Java classes, two of them actually holding interesting parts.
27 |
28 | ** Projection
29 |
30 | Using data projection we define a single interface, hiding the XML structure:
31 |
32 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#WeatherDataInterface|source=src/test/java/org/xmlbeam/tutorial/e01_weather/WeatherData.java}
33 |
34 | Hey, what does the inner interface "Location" do there? This declares that we like to group the two attributes holding the coordinates together in one object.
35 | It is not only possible to hide elements of the xml structure, but to enrich the structure with pretended objects.
36 |
37 | ** Example Code
38 |
39 | Here the code to run the example:
40 |
41 | %{include|charset=UTF-8|highlight-theme=eclipse|show-gutter=false|snippet=#WeatherDataCode|source=src/test/java/org/xmlbeam/tutorial/e01_weather/TestWeatherData.java}
42 |
43 | Notice that reading the data is just one line of code.
44 |
--------------------------------------------------------------------------------
/src/site/apt/t02.apt:
--------------------------------------------------------------------------------
1 | Tutorial 2
2 |
3 | *E02: Reading a Jenkins Job Configuration
4 |
5 | %{include|source-content-type=apt|snippet=#TutorialDescription|source=src/test/java/org/xmlbeam/tutorial/e02_jenkins/TestJenkinsConfigParsing.java}
6 |
7 | ** XML Content
8 |
9 | ** Model Interfaces
10 |
11 | Our example should read all builder and all publisher elements in the configuration file.
12 | We like to know the element names of both, so we define a super interface "ModelElement" and let our model objects extend it.
13 |
14 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#JenkinsModelElementInterface|source=src/test/java/org/xmlbeam/tutorial/e02_jenkins/model/ModelElement.java}
15 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#JenkinsPublisherInterface|source=src/test/java/org/xmlbeam/tutorial/e02_jenkins/model/Publisher.java}
16 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#JenkinsBuilderInterface|source=src/test/java/org/xmlbeam/tutorial/e02_jenkins/model/Builder.java}
17 |
18 | ** Projection API
19 |
20 | Now that we have our model objects defined, we need to define how to retrieve them.
21 |
22 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#JenkinsJobConfigInterface|source=src/test/java/org/xmlbeam/tutorial/e02_jenkins/JenkinsJobConfig.java}
23 |
24 | ** Example Code
25 |
26 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#JenkinsCode|source=src/test/java/org/xmlbeam/tutorial/e02_jenkins/TestJenkinsConfigParsing.java}
--------------------------------------------------------------------------------
/src/site/apt/t03.apt:
--------------------------------------------------------------------------------
1 | Tutorial 3
2 |
3 | %{include|source-content-type=apt|snippet=#TutorialDescription|source=src/test/java/org/xmlbeam/tutorial/e03_eclipse/TestEclipseCodeFormatterConfig.java}
4 |
5 | *XML Content
6 |
7 | -----------
8 |
9 |
10 |
13 |
16 | ...
17 |
18 |
19 |
22 |
25 | ...
26 |
27 |
28 | -----------
29 |
30 | * Projection API
31 |
32 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#EclipseCodeFormatterConfig|source=src/test/java/org/xmlbeam/tutorial/e03_eclipse/EclipseFormatterConfigFile.java}
33 |
34 | * Example Code
35 |
36 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#TestEclipseCodeFormatterConfig|source=src/test/java/org/xmlbeam/tutorial/e03_eclipse/TestEclipseCodeFormatterConfig.java}
37 |
--------------------------------------------------------------------------------
/src/site/apt/t04.apt:
--------------------------------------------------------------------------------
1 | Tutorial 4
2 |
3 | *E04: Reuse a subprojection to different Maven POM elements
4 |
5 | %{include|source-content-type=apt|snippet=#TutorialDescription|source=src/test/java/org/xmlbeam/tutorial/e04_maven/TestMavenPOM.java}
6 |
7 | * Projection API
8 |
9 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#MavenPOM|source=src/test/java/org/xmlbeam/tutorial/e04_maven/MavenPOM.java}
10 |
11 | * Example Code
12 |
13 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#TestMavenPOM|source=src/test/java/org/xmlbeam/tutorial/e04_maven/TestMavenPOM.java}
14 |
--------------------------------------------------------------------------------
/src/site/apt/t05.apt:
--------------------------------------------------------------------------------
1 | Tutorial 5
2 |
3 | *E05: Filtering a RSS feed
4 |
5 | %{include|source-content-type=apt|snippet=#TutorialDescription|source=src/test/java/org/xmlbeam/tutorial/e05_rss/TestFilterRSSFeed.java}
6 |
7 | *Projection API
8 |
9 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#SlashdotRSSFeed|source=src/test/java/org/xmlbeam/tutorial/e05_rss/SlashdotRSSFeed.java}
10 |
11 | *Example Code
12 |
13 | And here some unit tests to print out some data about our RSS feed.
14 |
15 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#=TestFilterRSSFeed|source=src/test/java/org/xmlbeam/tutorial/e05_rss/TestFilterRSSFeed.java}
16 |
--------------------------------------------------------------------------------
/src/site/apt/t06.apt:
--------------------------------------------------------------------------------
1 | Tutorial 6
2 |
3 | *E06: Creating a XHTML document from scratch
4 |
5 | %{include|source-content-type=apt|snippet=#TutorialDescription|source=src/test/java/org/xmlbeam/tutorial/e06_xhtml/TestCreationOfXHTMLDocument.java}
6 |
7 | * Create a new document from scratch
8 |
9 | * Usage of configuration injection to modify the output transformer.
10 |
11 | * Projection API
12 |
13 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#XHTML|source=src/test/java/org/xmlbeam/tutorial/e06_xhtml/XHTML.java}
14 |
15 | * Example Code
16 |
17 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#TestCreationOfXHTMLDocument|source=src/test/java/org/xmlbeam/tutorial/e06_xhtml/TestCreationOfXHTMLDocument.java}
18 |
--------------------------------------------------------------------------------
/src/site/apt/t07.apt:
--------------------------------------------------------------------------------
1 | Tutorial 7
2 |
3 | *E07: Using mixins to sort SVG elements
4 |
5 | %{include|source-content-type=apt|snippet=#TutorialDescription|source=src/test/java/org/xmlbeam/tutorial/e07_svg/TestSVGElementSorting.java}
6 |
7 | * Add behavior to projections by adding a Mixin.
8 |
9 | * Projection API
10 |
11 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#SVGDocument|source=src/test/java/org/xmlbeam/tutorial/e07_svg/SVGDocument.java}
12 |
13 | * Example Code
14 |
15 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#TestSVGElementSorting|source=src/test/java/org/xmlbeam/tutorial/e07_svg/TestSVGElementSorting.java}
16 |
--------------------------------------------------------------------------------
/src/site/apt/t08.apt:
--------------------------------------------------------------------------------
1 | Tutorial 8
2 |
3 | *E08: Demonstrating API Mimicry
4 |
5 | %{include|source-content-type=apt|snippet=#TutorialDescription|source=src/test/java/org/xmlbeam/tutorial/e08_api_mimicry/TestDom4jMimicry.java}
6 |
7 | * Projection API
8 |
9 | In this example we do something special:
10 |
11 | * Projection of a complete unknown XML structure.
12 |
13 | * Building our Java API analog to DOM4J.
14 |
15 | The result is a generic Java API you can use to analyze every XML document.
16 |
17 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#Document|source=src/test/java/org/xmlbeam/tutorial/e08_api_mimicry/Document.java}
18 |
19 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#Element|source=src/test/java/org/xmlbeam/tutorial/e08_api_mimicry/Element.java}
20 |
21 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#Attribute|source=src/test/java/org/xmlbeam/tutorial/e08_api_mimicry/Attribute.java}
22 |
23 | * Example Code
24 |
25 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#TestDom4jMimicry|source=src/test/java/org/xmlbeam/tutorial/e08_api_mimicry/TestDom4jMimicry.java}
26 |
27 |
--------------------------------------------------------------------------------
/src/site/apt/t09.apt:
--------------------------------------------------------------------------------
1 | Tutorial 9
2 |
3 | *E09 Bundling multiple documents to a virtual projection
4 |
5 | %{include|source-content-type=apt|snippet=#TutorialDescription|source=src/test/java/org/xmlbeam/tutorial/e09_dreambox/Dreambox.java}
6 |
7 | * Projection interface
8 |
9 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#Dreambox|source=src/test/java/org/xmlbeam/tutorial/e09_dreambox/Dreambox.java}
--------------------------------------------------------------------------------
/src/site/apt/t10.apt:
--------------------------------------------------------------------------------
1 | Tutorial 10
2 |
3 | *E10 Parsing HTML Documents
4 |
5 | %{include|source-content-type=apt|snippet=#TutorialDescription|source=src/test/java/org/xmlbeam/tutorial/e10_wikipedia/TestWikiAccess.java}
6 |
7 | * Projection
8 |
9 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#=ProgrammingLanguage|source=src/test/java/org/xmlbeam/tutorial/e10_wikipedia/ProgrammingLanguage.java}
10 |
11 | * Example Code
12 |
13 | This is the complete code as JUnit testcase.
14 | The pages are being loaded and parsed in just one line of code.
15 |
16 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#TestWikiAccess|source=src/test/java/org/xmlbeam/tutorial/e10_wikipedia/TestWikiAccess.java}
17 |
18 | * Test Output
19 | ~~
20 | James Gosling and Sun Microsystems designed Java
21 | Bjarne Stroustrup designed C++
22 | Dennis Ritchie designed C
23 | Martin Odersky designed Scala
24 |
--------------------------------------------------------------------------------
/src/site/apt/t12.apt:
--------------------------------------------------------------------------------
1 | Tutorial 12
2 |
3 | *E12 Creating 3D data using a document template
4 |
5 | %{include|source-content-type=apt|snippet=#TutorialDescription|source=src/test/java/org/xmlbeam/tutorial/e12_xml3d/RunExample.java}
6 |
7 | * Projection
8 |
9 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#Xml3d|source=src/test/java/org/xmlbeam/tutorial/e12_xml3d/Xml3d.java}
10 |
11 | * Example Code
12 |
13 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#RunExample|source=src/test/java/org/xmlbeam/tutorial/e12_xml3d/RunExample.java}
14 |
--------------------------------------------------------------------------------
/src/site/apt/t13.apt:
--------------------------------------------------------------------------------
1 | Tutorial 13
2 |
3 | *E13 Creating subprojections with element templates
4 |
5 | %{include|source-content-type=apt|snippet=#TutorialDescription|source=src/test/java/org/xmlbeam/tutorial/e13_graphml/TestGraphMLCreation.java}
6 |
7 |
8 | * Projections
9 |
10 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#Node|source=src/test/java/org/xmlbeam/tutorial/e13_graphml/Node.java}
11 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#Edge|source=src/test/java/org/xmlbeam/tutorial/e13_graphml/Edge.java}
12 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#GraphML|source=src/test/java/org/xmlbeam/tutorial/e13_graphml/GraphML.java}
13 |
14 |
15 |
16 | * Example Code
17 |
18 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#TestGraphMLCreation|source=src/test/java/org/xmlbeam/tutorial/e13_graphml/TestGraphMLCreation.java}
19 |
--------------------------------------------------------------------------------
/src/site/apt/t14.apt:
--------------------------------------------------------------------------------
1 | Tutorial 14
2 |
3 | *E14 Using a custom type conversion to modify KML coordinates
4 |
5 | %{include|source-content-type=apt|snippet=#TutorialDescription|source=src/test/java/org/xmlbeam/tutorial/e14_kml/TestCustomTypeConversion.java}
6 |
7 | * Projection
8 |
9 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#KML|source=src/test/java/org/xmlbeam/tutorial/e14_kml/KML.java}
10 |
11 |
12 | * Example Code
13 |
14 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#TestCustomTypeConversion|source=src/test/java/org/xmlbeam/tutorial/e14_kml/TestCustomTypeConversion.java}
15 |
--------------------------------------------------------------------------------
/src/site/apt/t15.apt:
--------------------------------------------------------------------------------
1 | Tutorial 15
2 |
3 | *E15 Reading a complex plist structure and deriving the XPath from method names
4 |
5 | %{include|source-content-type=apt|snippet=#TutorialDescription|source=src/test/java/org/xmlbeam/tutorial/e15_plist/TestPlistAccess.java}
6 |
7 | * XML Data
8 |
9 | %{include|highlight-theme=eclipse|show-gutter=false|source=src/test/java/org/xmlbeam/tutorial/e15_plist/example.plist}
10 |
11 | * Projection
12 |
13 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#PList|source=src/test/java/org/xmlbeam/tutorial/e15_plist/PList.java}
14 |
15 |
16 | * Example Code
17 |
18 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#TestPlistAccess|source=src/test/java/org/xmlbeam/tutorial/e15_plist/TestPlistAccess.java}
19 |
--------------------------------------------------------------------------------
/src/site/apt/t16.apt:
--------------------------------------------------------------------------------
1 | Tutorial 16
2 |
3 | *E16 Using an XML schema to define default values and validate documents
4 |
5 | %{include|source-content-type=apt|snippet=#TutorialDescription|source=src/test/java/org/xmlbeam/tutorial/e16_schemaHandling/TestSchemaHandling.java}
6 |
7 | * XML Data
8 |
9 | %{include|highlight-theme=eclipse|show-gutter=false|source=src/test/java/org/xmlbeam/tutorial/e16_schemaHandling/schema.xsd}
10 |
11 | %{include|highlight-theme=eclipse|show-gutter=false|source=src/test/java/org/xmlbeam/tutorial/e16_schemaHandling/vegetables.xml}
12 |
13 | * Projection
14 |
15 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#SchemaHandling|source=src/test/java/org/xmlbeam/tutorial/e16_schemaHandling/Vegetable.java}
16 |
17 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#SchemaHandling|source=src/test/java/org/xmlbeam/tutorial/e16_schemaHandling/Vegetables.java}
18 |
19 |
20 | * Example Code
21 |
22 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#SchemaHandling|source=src/test/java/org/xmlbeam/tutorial/e16_schemaHandling/TestSchemaHandling.java}
23 |
--------------------------------------------------------------------------------
/src/site/apt/t18.apt:
--------------------------------------------------------------------------------
1 | Tutorial 18
2 |
3 | *E18 Using XMLBeam without a projection interface to resolve a postal code
4 |
5 | %{include|source-content-type=apt|snippet=#TutorialDescription|source=src/test/java/org/xmlbeam/tutorial/e18_postalCodeRetrieval/RetrievePostalCodeTest.java}
6 |
7 | * XML Data
8 |
9 | The postal code is stored in one of many address_component elements.
10 | With data binding you would need to iterate over all of these elements to find the one containing the postal code.
11 |
12 | %{include|highlight-theme=eclipse|show-gutter=false|source=src/test/java/org/xmlbeam/tutorial/e18_postalCodeRetrieval/data.xml}
13 |
14 | * Example Code
15 |
16 | You only need just one line of code to read the postal code. You do not need even a projection interface in this case.
17 |
18 | %{include|highlight-theme=eclipse|show-gutter=false|snippet=#RetrievePostalCode|source=src/test/java/org/xmlbeam/tutorial/e18_postalCodeRetrieval/RetrievePostalCodeTest.java}
19 |
--------------------------------------------------------------------------------
/src/site/apt/tipsandtricks.apt:
--------------------------------------------------------------------------------
1 | Tips & Tricks
2 |
3 | * XPath
4 |
5 | * Default NS
6 |
7 | * Use XPath variables instead of preprocessor arguments
8 |
9 | * Projection Methods
10 |
11 | * Return Type Declaration
12 |
13 | * Optional Return Type
14 |
15 | * Return "this"
16 |
17 | * Return int on update projection
18 |
19 | * Declare pojection method throwing an exception
20 |
21 | * Type conversion
22 |
23 | * Value types with Constructor
24 |
25 | * Value types with Factory
26 |
27 | * Formats
28 |
29 | * Use a format for reading and writing
30 |
31 | * Projections
32 |
33 | * Projection uses itself as subprojection
--------------------------------------------------------------------------------
/src/site/resources/attached-includes/css/.gitignore:
--------------------------------------------------------------------------------
1 | /shCoreEclipse.css
2 | /shCoreEclipse.css.gz
3 |
--------------------------------------------------------------------------------
/src/site/resources/attached-includes/css/shCoreDefault.css.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SvenEwald/xmlbeam/84a2a91c216622c611a948d88792c846b532aa0a/src/site/resources/attached-includes/css/shCoreDefault.css.gz
--------------------------------------------------------------------------------
/src/site/resources/images/about3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SvenEwald/xmlbeam/84a2a91c216622c611a948d88792c846b532aa0a/src/site/resources/images/about3.png
--------------------------------------------------------------------------------
/src/site/resources/robots.txt:
--------------------------------------------------------------------------------
1 | User-agent: *
2 | Disallow: /apidocs
--------------------------------------------------------------------------------
/src/site/resources/sitemap.txt:
--------------------------------------------------------------------------------
1 | http://xmlbeam.org/index.html
2 | http://xmlbeam.org/introduction.html
3 | http://xmlbeam.org/tutorials.html
4 | http://xmlbeam.org/refcards.html
5 | http://xmlbeam.org/faq.html
6 | http://xmlbeam.org/links.html
7 | http://xmlbeam.org/about.html
--------------------------------------------------------------------------------
/src/srcbuild/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Bundle-ManifestVersion: 2
3 | Eclipse-SourceBundle: org.xmlbeam.xmlprojector;version="x.x.x";roots="."
4 | Bundle-Name: XMLBeam
5 | Bundle-SymbolicName: org.xmlbeam.xmlprojector.source
6 | Bundle-Version: x.x.x
7 | Bunlde-Vendor:XMLBeam.org
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/refcards/SpecifyProjectorUsage.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.refcards;
17 |
18 | import java.io.IOException;
19 |
20 | import org.xmlbeam.XBProjector;
21 | import org.xmlbeam.XBProjector.Flags;
22 | import org.xmlbeam.config.DefaultXMLFactoriesConfig;
23 |
24 | /**
25 | *
26 | */
27 | @SuppressWarnings("javadoc")
28 | public class SpecifyProjectorUsage {
29 |
30 |
31 | public void testFluentAPI() throws IOException {
32 |
33 | new XBProjector(Flags.SYNCHRONIZE_ON_DOCUMENTS).projectEmptyDocument(null);
34 | new XBProjector(Flags.SYNCHRONIZE_ON_DOCUMENTS, Flags.TO_STRING_RENDERS_XML).io().fromURLAnnotation(null);
35 |
36 | }
37 |
38 | public void testXMLFactoriesConfig() {
39 | {
40 | DefaultXMLFactoriesConfig config = new DefaultXMLFactoriesConfig();
41 | config.setPrettyPrinting(true);
42 | XBProjector projector = new XBProjector(config);
43 | projector.hashCode();
44 | }
45 | {
46 | XBProjector projector = new XBProjector();
47 | projector.config().as(DefaultXMLFactoriesConfig.class).setPrettyPrinting(true);
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/refcards/namespaces/NameSpaceProjection.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 Sven Ewald
3 | *
4 | * This file is part of JSONBeam.
5 | *
6 | * JSONBeam is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, any
9 | * later version.
10 | *
11 | * JSONBeam is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with JSONBeam. If not, see .
18 | */
19 | package org.xmlbeam.refcards.namespaces;
20 |
21 | import org.xmlbeam.annotation.XBDocURL;
22 | import org.xmlbeam.annotation.XBRead;
23 |
24 | @SuppressWarnings("javadoc")
25 | @XBDocURL("resource://nstest.xml")
26 | public interface NameSpaceProjection {
27 |
28 | @XBRead("//table")
29 | String getTable();
30 |
31 | @XBRead("//h:table")
32 | String getNamepsacedTable();
33 |
34 | @XBRead("//xbdefaultns:table")
35 | String getDefaultNamepsacedTable();
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/refcards/namespaces/nstest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Apples
7 | Bananas
8 |
9 |
10 |
11 |
12 |
13 | African Coffee Table
14 | 80
15 | 120
16 |
17 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/refcards/namespaces/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * @author sven
18 | * This package holds demo code to explain the usage of namespaces.
19 | */
20 | package org.xmlbeam.refcards.namespaces;
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/refcards/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * The package contains no tests, but documentation snippets that should at least compile.
18 | */
19 | package org.xmlbeam.refcards;
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/refcards/xgml/Section.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2017 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.refcards.xgml;
17 |
18 | import org.xmlbeam.annotation.XBRead;
19 | import org.xmlbeam.types.XBAutoValue;
20 |
21 | /**
22 | *
23 | */
24 | public interface Section {
25 |
26 | @XBRead("./@name")
27 | XBAutoValue name();
28 |
29 | @XBRead("./attribute[@key='id'][@type='int']")
30 | XBAutoValue id();
31 |
32 | @XBRead("./attribute[@key='text'][@type='String']")
33 | XBAutoValue text();
34 |
35 | @XBRead("./section[@name='LabelGraphics']/attribute[@key='text'][@type='String']")
36 | XBAutoValue label();
37 |
38 | @XBRead("./attribute[@key='source'][@type='int']")
39 | XBAutoValue source();
40 |
41 | @XBRead("./attribute[@key='target'][@type='int']")
42 | XBAutoValue target();
43 |
44 | @XBRead("./section[@name='graphics']/attribute[@key='targetArrow'][@type='String']")
45 | XBAutoValue graphics();
46 |
47 | @XBRead("./section[@name='graphics']/attribute[@key='fill'][@type='String']")
48 | XBAutoValue fill();
49 |
50 | @XBRead("./section[@name='graphics']/attribute[@key='w'][@type='double']")
51 | XBAutoValue widh();
52 |
53 |
54 | }
55 |
56 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/refcards/xgml/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2017 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | *
18 | */
19 | package org.xmlbeam.refcards.xgml;
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/GenericXPathProjection.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tests;
17 |
18 | import org.xmlbeam.annotation.XBRead;
19 | import org.xmlbeam.annotation.XBValue;
20 | import org.xmlbeam.annotation.XBWrite;
21 | import org.xmlbeam.dom.DOMAccess;
22 | @SuppressWarnings("javadoc")
23 | public interface GenericXPathProjection extends DOMAccess {
24 |
25 | @XBWrite("{0}")
26 | void setterXPathString(String path, @XBValue String value);
27 |
28 | @XBWrite("{0}")
29 | void setterXPathProjection(String path,@XBValue GenericXPathProjection projection);
30 |
31 | @XBRead("{0}")
32 | String getXPathValue(String path);
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/SecurityTests.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tests;
17 |
18 | import static org.junit.Assert.assertTrue;
19 |
20 | import java.util.Map;
21 |
22 | import org.junit.Test;
23 | import org.xmlbeam.XBProjector;
24 |
25 | /**
26 | * @author sven
27 | *
28 | */
29 | public class SecurityTests {
30 |
31 | private final static String XML="\n" +
32 | " \n" +
34 | " ]>&xxe;";
35 |
36 | @Test
37 | public void badEntityResolver() {
38 | Map map = new XBProjector().onXMLString(XML).createMapOf(String.class);
39 | assertTrue(map.isEmpty());
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/autovalues/TestAutoListOfAutoMaps.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2017 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tests.autovalues;
17 |
18 | import org.junit.Test;
19 |
20 | /**
21 | * @author sven
22 | */
23 | public class TestAutoListOfAutoMaps {
24 |
25 | @Test
26 | public void testCreateListOfMaps() {
27 | // List> list = new XBProjector().onXMLString("").evalXPath("/xml/list/entry").asListOf(XBAutoMap.class);
28 | // list.toString();
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/bugs/TestAttributeWriteToRootDocNode.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tests.bugs;
17 |
18 | import org.junit.Test;
19 | import org.xmlbeam.XBProjector;
20 | import org.xmlbeam.annotation.XBWrite;
21 | import org.xmlbeam.exceptions.XBPathException;
22 |
23 | /**
24 | * @author sven
25 | *
26 | */
27 | @SuppressWarnings("javadoc")
28 | public class TestAttributeWriteToRootDocNode {
29 |
30 | public interface Projection {
31 | @XBWrite("./@attri")
32 | void nonExistingAttribute(String x);
33 | }
34 |
35 | @Test(expected=XBPathException.class)
36 | public void testWrongWritePath() {
37 | Projection projection = new XBProjector().projectEmptyDocument(Projection.class);
38 | projection.nonExistingAttribute("foo");
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/bugs/TestBug51ClassCastException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tests.bugs;
17 |
18 | import static org.junit.Assert.*;
19 |
20 | import org.junit.Test;
21 | import org.xmlbeam.XBProjector;
22 | import org.xmlbeam.XBProjector.Flags;
23 | import org.xmlbeam.annotation.XBWrite;
24 |
25 | /**
26 | * @author sven
27 | *
28 | */
29 | public class TestBug51ClassCastException {
30 | public interface Child {
31 | @XBWrite("ChildData")
32 | void setData(String data);
33 | }
34 |
35 | public interface ParentNoRootElement {
36 |
37 | @XBWrite("/*")
38 | void setChild(Child child);
39 | }
40 |
41 | @Test
42 | public void testSetChildOnParentAsDocumentRoot() {
43 | XBProjector projector = new XBProjector(Flags.TO_STRING_RENDERS_XML);
44 |
45 | ParentNoRootElement parent = projector.projectEmptyDocument(ParentNoRootElement.class);
46 |
47 | Child child = projector.projectEmptyElement("Child",Child.class);
48 | child.setData("child data...");
49 | parent.setChild(child);
50 | System.out.println("Result: " + parent);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/bugs/TestElementCreationWithDotInName.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tests.bugs;
17 |
18 | import org.junit.Test;
19 | import org.xmlbeam.XBProjector;
20 | import org.xmlbeam.XBProjector.Flags;
21 | import org.xmlbeam.annotation.XBWrite;
22 |
23 | @SuppressWarnings("javadoc")
24 | public class TestElementCreationWithDotInName {
25 |
26 | public interface Projection {
27 | @XBWrite("/root/{0}/content")
28 | Projection write(String elementName);
29 | }
30 |
31 | @Test
32 | public void testDotInSetterName() {
33 | Projection projection = new XBProjector(Flags.TO_STRING_RENDERS_XML).projectEmptyDocument(Projection.class);
34 | projection.write("abc.def");
35 | //System.out.println(projection);
36 | //assertEquals("")
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/bugs/TestFloatReturnsNull.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tests.bugs;
17 |
18 | import static org.junit.Assert.assertNull;
19 |
20 | import org.junit.Test;
21 | import org.xmlbeam.XBProjector;
22 | import org.xmlbeam.annotation.XBRead;
23 | import org.xmlbeam.types.DefaultTypeConverter;
24 | import org.xmlbeam.types.DefaultTypeConverter.Conversion;
25 |
26 | /**
27 | *
28 | */
29 | @SuppressWarnings({ "javadoc", "serial" })
30 | public class TestFloatReturnsNull {
31 |
32 | public interface Issue19 {
33 |
34 | @XBRead("/foo/@nonexisting")
35 | Float getFloat();
36 |
37 | }
38 |
39 | @Test
40 | public void testIssue19() {
41 | final XBProjector projector = new XBProjector();
42 | Conversion floatConversion = new Conversion(null) {
43 | @Override
44 | public Float convert(final String data) {
45 | return Float.valueOf(data);
46 | }
47 | };
48 | projector.config().getTypeConverterAs(DefaultTypeConverter.class).setConversionForType(Float.class, floatConversion);
49 | final Issue19 issue19 = projector.projectXMLString("", Issue19.class);
50 | assertNull(issue19.getFloat());
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/bugs/TestStartsWithXpathFunction.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tests.bugs;
17 |
18 | import static org.junit.Assert.assertFalse;
19 | import static org.junit.Assert.assertTrue;
20 |
21 | import org.junit.Test;
22 | import org.xmlbeam.XBProjector;
23 | import org.xmlbeam.annotation.XBRead;
24 |
25 | /**
26 | * Testcase to cover bug report #18
27 | */
28 | @SuppressWarnings("javadoc")
29 | public class TestStartsWithXpathFunction {
30 |
31 | public interface Issue18 {
32 | @XBRead("starts-with('{0}','{1}')")
33 | boolean startsWith(String text, String prefix);
34 | }
35 |
36 | @Test
37 | public void testStartsWithXpathFunction() {
38 | Issue18 issue18 = new XBProjector().projectEmptyDocument(Issue18.class);
39 |
40 | assertTrue(issue18.startsWith("12345", "123"));
41 | assertFalse(issue18.startsWith("12345", "23"));
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/bugs/bug38/SOAPResponse.java:
--------------------------------------------------------------------------------
1 | package org.xmlbeam.tests.bugs.bug38;
2 |
3 | import org.xmlbeam.annotation.XBRead;
4 |
5 | @SuppressWarnings("javadoc")
6 | public interface SOAPResponse {
7 |
8 | @XBRead("/soap:Envelope/soap:Body")
9 | Body getBody();
10 |
11 | interface Body {
12 | // @XBRead("./ns1:storeTokenResponse/ns1:result")
13 | @XBRead("./ns1:storeTokenResponse/ns1:result")
14 | Result getResult();
15 | }
16 |
17 | interface Result {
18 |
19 | @XBRead("./ns1:alias")
20 | String getAlias();
21 |
22 | @XBRead("./ns1:aliasType")
23 | String getAliasType();
24 |
25 | @XBRead("./ns1:pspReference")
26 | String getPspReference();
27 |
28 | @XBRead("./ns1:recurringDetailReference")
29 | String getRecurringDetailReference();
30 |
31 | @XBRead("./ns1:result")
32 | String getResult();
33 |
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/bugs/bug38/TestSoapReading.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2017 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tests.bugs.bug38;
17 |
18 | import org.junit.Assert;
19 | import org.junit.Test;
20 | import org.xmlbeam.XBProjector;
21 | import org.xmlbeam.XBProjector.Flags;
22 | import org.xmlbeam.tests.bugs.bug38.SOAPResponse.Result;
23 |
24 | @SuppressWarnings("javadoc")
25 | public class TestSoapReading {
26 |
27 | private final static XBProjector projector = new XBProjector(Flags.TO_STRING_RENDERS_XML);
28 |
29 | @Test
30 | public void canParseXML() throws Exception {
31 |
32 | SOAPResponse soapResponse = projector.io().url("res://soap.xml").read(SOAPResponse.class);
33 | Assert.assertNotNull(soapResponse.getBody());
34 |
35 | Result result = soapResponse.getBody().getResult();
36 | Assert.assertNotNull(result);
37 |
38 | Assert.assertEquals("B133243153928547", result.getAlias());
39 | Assert.assertEquals("Default", result.getAliasType());
40 | Assert.assertEquals("8514873382743402", result.getPspReference().trim());
41 | Assert.assertEquals("8414873382748121", result.getRecurringDetailReference().trim());
42 | Assert.assertEquals("Success", result.getResult());
43 |
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/bugs/bug38/soap.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
9 | B133243153928547
10 | Default
11 |
12 |
14 | 8514873382743402
15 | 8414873382748121
16 |
17 |
19 |
21 | Success
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/bugs/bug54/BaseObject.java:
--------------------------------------------------------------------------------
1 | package org.xmlbeam.tests.bugs.bug54;
2 |
3 | import java.util.List;
4 |
5 | import org.xmlbeam.annotation.XBRead;
6 | import org.xmlbeam.annotation.XBWrite;
7 |
8 | public interface BaseObject {
9 |
10 | @XBRead ("/base/@id")
11 | public int getId();
12 |
13 | @XBWrite ("/base/@id")
14 | public void setId(int id);
15 |
16 | @XBRead ("/base/color")
17 | public int getColor();
18 |
19 | @XBWrite ("/base/color")
20 | public void setColor(int color);
21 |
22 | @XBRead ("/base/foo/bar/subs/subObject")
23 | public List< SubObject > getSubObjects();
24 |
25 | @XBWrite ("/base/foo/bar/subs/subObject")
26 | public void setSubObjects(List< SubObject > subObjects);
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/bugs/bug54/SubObject.java:
--------------------------------------------------------------------------------
1 | package org.xmlbeam.tests.bugs.bug54;
2 |
3 | import org.xmlbeam.annotation.XBRead;
4 | import org.xmlbeam.annotation.XBWrite;
5 |
6 | public interface SubObject {
7 |
8 | @XBRead("./@id")
9 | public int getId();
10 |
11 | @XBWrite("./@id")
12 | public void setId(int id);
13 |
14 | @XBRead(".")
15 | public String getText();
16 |
17 | @XBWrite(".")
18 | public void setText(String text);
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/bugs/bug54/XBTest.java:
--------------------------------------------------------------------------------
1 | package org.xmlbeam.tests.bugs.bug54;
2 |
3 | import static org.junit.Assert.assertEquals;
4 | import static org.junit.Assert.assertTrue;
5 |
6 | import java.io.IOException;
7 | import java.util.ArrayList;
8 | import java.util.List;
9 |
10 | import org.junit.Test;
11 | import org.xmlbeam.XBProjector;
12 |
13 | public class XBTest {
14 |
15 | @Test
16 | public void xml2Object() throws IOException {
17 |
18 | XBProjector projector = new XBProjector();
19 | BaseObject fromFile = projector.io().file("src/test/java/org/xmlbeam/tests/bugs/bug54/xb.xml").read(BaseObject.class);
20 |
21 | assertEquals(1, fromFile.getId());
22 | assertEquals(5, fromFile.getColor());
23 |
24 | SubObject subObject = fromFile.getSubObjects().get(0);
25 |
26 | assertEquals(2, subObject.getId());
27 | assertEquals("The description", subObject.getText());
28 | }
29 |
30 | @Test
31 | public void object2Xml() {
32 |
33 | XBProjector projector = new XBProjector();
34 |
35 | BaseObject baseObject = projector.projectEmptyDocument(BaseObject.class);
36 |
37 | baseObject.setId(1);
38 | baseObject.setColor(123);
39 |
40 | SubObject subObject = projector.projectEmptyElement("SubObject", SubObject.class);
41 | subObject.setId(456);
42 | subObject.setText("The text");
43 |
44 | List< SubObject > subs = new ArrayList();
45 | subs.add(subObject);
46 | baseObject.setSubObjects(subs);
47 |
48 | String xml = projector.asString(baseObject);
49 |
50 | System.out.println(xml);
51 |
52 | assertTrue(xml.contains("123")); // OK
53 | assertTrue(xml.contains("456")); // fails!
54 |
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/bugs/bug54/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * @author sven
18 | *
19 | */
20 | package org.xmlbeam.tests.bugs.bug54;
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/bugs/bug54/xb.xml:
--------------------------------------------------------------------------------
1 |
2 | 5
3 |
4 |
5 |
6 | The description
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/bugs/bug55/SimpleTest.java:
--------------------------------------------------------------------------------
1 | package org.xmlbeam.tests.bugs.bug55;
2 |
3 | import static org.junit.Assert.*;
4 |
5 | import org.junit.Test;
6 |
7 | import org.w3c.dom.Node;
8 |
9 | import org.xmlbeam.XBProjector;
10 | import org.xmlbeam.types.XBAutoMap;
11 |
12 | public class SimpleTest {
13 |
14 | @Test
15 | public void test1() {
16 | // fetch the node, this works fine
17 | String xml2 = "";
18 | XBAutoMap map2 = new XBProjector().onXMLString(xml2).createMapOf(Node.class);
19 | String c2 = map2.get("//a/b").getTextContent();
20 | assertEquals("c", c2);
21 | }
22 |
23 | @Test
24 | public void test2() {
25 | // no cdata, works with String
26 | String xml = "c";
27 | XBAutoMap map = new XBProjector().onXMLString(xml).createMapOf(String.class);
28 | String c = map.get("//a/b");
29 | assertEquals("c", c);
30 | }
31 |
32 | @Test
33 | public void test2b() {
34 | // but this doesn't work, it should
35 | String xml = "c";
36 | XBAutoMap map2 = new XBProjector().onXMLString(xml).createMapOf(String.class);
37 | String c2 = map2.get("//a/b/text()");
38 | assertEquals("c", c2);
39 | }
40 |
41 | @Test
42 | public void test3() {
43 | // this fails
44 | String xml = "";
45 | XBAutoMap map = new XBProjector().onXMLString(xml).createMapOf(String.class);
46 | String c = map.get("//a/b");
47 | assertEquals("c", c);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/bugs/bug55/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * @author se
18 | *
19 | */
20 | package org.xmlbeam.tests.bugs.bug55;
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/bugs/bug58/KfwKonditionsDokument.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tests.bugs.bug58;
17 |
18 | import java.util.List;
19 |
20 | import org.xmlbeam.annotation.XBRead;
21 |
22 | public interface KfwKonditionsDokument {
23 |
24 | @XBRead("/konditionen/bankengruppe/programmgruppe/programm/variante/preiskategorie")
25 | public List getEintraege();
26 | }
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/bugs/bug58/KfwPreiskategorie.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tests.bugs.bug58;
17 |
18 |
19 | import java.util.List;
20 |
21 | import org.xmlbeam.annotation.XBRead;
22 |
23 | public interface KfwPreiskategorie {
24 |
25 | @XBRead("../../@nummer")
26 | public int getProgrammNummer();
27 | @XBRead("../../@name")
28 | public String getProgrammName();
29 | @XBRead("../../@auszahlungskurs")
30 | public String getProgrammAuszahlungskurs();
31 | @XBRead("../../@provision")
32 | public String getProgrammProvision();
33 | @XBRead("../@laufzeit")
34 | public int getVarianteLaufzeit();
35 | @XBRead("../@tilgungsfreie_anlaufjahre")
36 | public int getVarianteTilgunsfreieJahre();
37 | @XBRead("../@zinsbindung")
38 | public int getVarianteZinsbindungJahre();
39 | @XBRead("../@haftungsfreistellung")
40 | public int getVarianteHaftungsfreistellung();
41 | @XBRead("./@key")
42 | public String getKey();
43 | @XBRead("./@gueltig_ab")
44 | public String getGueltigAb();
45 | @XBRead("./anmerkungen/anmerkung/text()")
46 | public List getAnmerkungen();
47 | @XBRead("./ekn/zinssatz/@nominal")
48 | public String getNominalZins();
49 | @XBRead("./ekn/zinssatz/@effektiv")
50 | public String getEffektivZins();
51 |
52 |
53 | }
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/bugs/bug58/TestBug58.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tests.bugs.bug58;
17 |
18 | import static org.junit.Assert.assertEquals;
19 |
20 | import java.io.IOException;
21 | import java.io.InputStream;
22 | import java.nio.charset.Charset;
23 | import java.util.Scanner;
24 |
25 | import org.junit.Test;
26 | import org.xmlbeam.XBProjector;
27 |
28 | public class TestBug58 {
29 | @SuppressWarnings("unused")
30 | @Test
31 | public void test() throws IOException {
32 |
33 | Charset UTF_8 = Charset.forName("UTF-8");
34 | String xml = IOUtilstoString(getClass().getResourceAsStream("/org/xmlbeam/tests/bugs/bug58/Konditionen_Bank.xml"), UTF_8);
35 |
36 | KfwKonditionsDokument konditionen = new XBProjector().projectXMLString(xml, KfwKonditionsDokument.class);
37 |
38 | assertEquals(1948, konditionen.getEintraege().size());
39 |
40 | KfwKonditionsDokument konditionen2 = new XBProjector().projectXMLString(xml, KfwKonditionsDokument.class); // fails since 1.4.15
41 |
42 | }
43 |
44 | /**
45 | * @param resourceAsStream
46 | * @param uTF_8
47 | * @return
48 | */
49 | private String IOUtilstoString(InputStream resourceAsStream, Charset uTF_8) {
50 | return new Scanner(resourceAsStream).useDelimiter("\\Z").next();
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/bugs/bug61/TextNodeTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2022 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tests.bugs.bug61;
17 |
18 | import static org.junit.Assert.assertEquals;
19 |
20 | import org.junit.Test;
21 | import org.xmlbeam.XBProjector;
22 | import org.xmlbeam.XBProjector.Flags;
23 | import org.xmlbeam.annotation.XBRead;
24 |
25 | public class TextNodeTest {
26 |
27 | interface Item {
28 | @XBRead("/item/text()")
29 | String getText();
30 | }
31 |
32 | @Test
33 | public void testWhitespaceOnlyTextNode() {
34 | XBProjector projector = new XBProjector(Flags.TO_STRING_RENDERS_XML);
35 | final Item item = projector.onXMLString("").createProjection(Item.class);
36 | // ((DOMAccess)item).getDOMNode();
37 | //DOMHelper.
38 | //System.out.println(item.toString());
39 |
40 | assertEquals(" ", item.getText());
41 | }
42 | }
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/bugs/bug62/xmlwithns.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 0
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/demo/TestNodeContains.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tests.demo;
17 |
18 | import static org.junit.Assert.assertEquals;
19 |
20 | import java.io.IOException;
21 |
22 | import org.junit.Test;
23 | import org.xmlbeam.XBProjector;
24 | import org.xmlbeam.annotation.XBDocURL;
25 | import org.xmlbeam.annotation.XBRead;
26 |
27 | @SuppressWarnings("javadoc")
28 | public class TestNodeContains {
29 |
30 | @XBDocURL("resource://book.xml")
31 | public interface Books {
32 |
33 | @XBRead("//verse[contains(text(),'{0}')]")
34 | String lookup(String string);
35 |
36 | }
37 |
38 | @Test
39 | public void testXpathContains() throws IOException {
40 | Books books = new XBProjector().io().fromURLAnnotation(Books.class);
41 | assertEquals("Some texts are here. This text is gonna be long paragraph word", books.lookup("word"));
42 |
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/demo/book.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Some texts are here. This text is gonna be long paragraph
5 | Some texts are here. This text is gonna be long paragraph word
6 | Some texts are here. This text is gonna be long paragraph
7 | Some texts are here. This text is gonna be long paragraph
8 |
9 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/doc/GraphML.java:
--------------------------------------------------------------------------------
1 | /************************************************************************
2 | * *
3 | * DDDD SSSS AAA Daten- und Systemtechnik Aachen GmbH *
4 | * D D SS A A Pascalstrasse 28 *
5 | * D D SSS AAAAA 52076 Aachen-Oberforstbach, Germany *
6 | * D D SS A A Telefon: +49 (0)2408 / 9492-0 *
7 | * DDDD SSSS A A Telefax: +49 (0)2408 / 9492-92 *
8 | * *
9 | * *
10 | * (c) Copyright by DSA - all rights reserved *
11 | * *
12 | ************************************************************************
13 | *
14 | * Initial Creation:
15 | * Author se
16 | * Created on 08.04.2013
17 | *
18 | ************************************************************************/
19 | package org.xmlbeam.tests.doc;
20 |
21 | import java.util.List;
22 |
23 | import org.xmlbeam.annotation.XBDocURL;
24 | import org.xmlbeam.annotation.XBRead;
25 |
26 | @SuppressWarnings("javadoc")
27 | @XBDocURL("resource://XBProjector-Sheet-compact.graphml")
28 | public interface GraphML {
29 |
30 | @XBRead("//xbdefaultns:edge[@target='{0}']/@source")
31 | String getParentOf(String node);
32 |
33 | @XBRead(value = "//xbdefaultns:edge[@source='{0}']/@target")
34 | List getChildrenOf(String node);
35 |
36 | @XBRead("//xbdefaultns:node[@id='{0}']")
37 | Node getNode(String id);
38 |
39 | @XBRead("//xbdefaultns:node[normalize-space(//y:NodeLabel)='new XBProjector()']")
40 | Node getRootNode();
41 | }
42 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/doc/Node.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 Sven Ewald
3 | *
4 | * This file is part of JSONBeam.
5 | *
6 | * JSONBeam is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, any
9 | * later version.
10 | *
11 | * JSONBeam is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with JSONBeam. If not, see .
18 | */
19 | package org.xmlbeam.tests.doc;
20 |
21 | import org.xmlbeam.annotation.XBRead;
22 |
23 | @SuppressWarnings("javadoc")
24 | public interface Node {
25 |
26 | @XBRead("./xbdefaultns:data[@key='d4']")
27 | String getURL();
28 |
29 | @XBRead("normalize-space(./xbdefaultns:data/y:ShapeNode/y:NodeLabel)")
30 | String getLabel();
31 |
32 | @XBRead("./@id")
33 | String getID();
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/doc/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * @author sven
18 | * Package with tests that ensure the correctness of the documentation.
19 | */
20 | package org.xmlbeam.tests.doc;
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/evaluationapi/TestSimpleCreateAPI.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tests.evaluationapi;
17 |
18 | import static org.junit.Assert.assertEquals;
19 | import static org.junit.Assert.assertSame;
20 |
21 | import org.junit.Test;
22 | import org.xmlbeam.XBProjector;
23 | import org.xmlbeam.dom.DOMAccess;
24 |
25 | @SuppressWarnings("javadoc")
26 | public class TestSimpleCreateAPI {
27 |
28 | @Test
29 | public void testCreateViaDOMAccess() {
30 | DOMAccess projection = new XBProjector().projectEmptyDocument(DOMAccess.class);
31 | assertSame(projection,projection.create("/foo/bar/@value", "123"));
32 | assertEquals(new XBProjector().projectXMLString("", DOMAccess.class).asString(), projection.asString());
33 | System.out.println(projection.asString());
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/evaluationapi/data.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 123
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/external_document.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/format/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * @author sven
18 | *
19 | */
20 | package org.xmlbeam.tests.format;
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/inheritance/TestProjectionOverriding.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tests.inheritance;
17 |
18 | import static org.junit.Assert.*;
19 |
20 | import org.junit.Test;
21 | import org.xmlbeam.XBProjector;
22 | import org.xmlbeam.annotation.XBRead;
23 |
24 | @SuppressWarnings("javadoc")
25 | public class TestProjectionOverriding {
26 |
27 | public interface BaseProjection {
28 | @XBRead("string(1)")
29 | int getNumber();
30 |
31 | @XBRead("string(3)")
32 | int getAnotherNumber();
33 | }
34 |
35 | public interface ExtendedProjection extends BaseProjection {
36 | @XBRead("string(2)")
37 | int getNumber();
38 |
39 | @XBRead("string(4)")
40 | int getAnotherNumber(String withParam);
41 |
42 | @XBRead("string(5)")
43 | int withOutParam();
44 | }
45 |
46 | @Test
47 | public void testOverriding() {
48 | BaseProjection projection = new XBProjector().projectEmptyDocument(BaseProjection.class);
49 | assertEquals(1,projection.getNumber());
50 |
51 | ExtendedProjection subProjection = new XBProjector().projectEmptyDocument(ExtendedProjection.class);
52 | assertEquals(2,subProjection.getNumber());
53 | assertEquals(3,subProjection.getAnotherNumber());
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/namespaces/DocumentWithNamespaces.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | I have no namespace.
7 |
8 |
9 | I have a prefix.
10 |
11 |
12 |
13 | I have a default namespace.
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/namespaces/NamespacedProjection.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tests.namespaces;
17 |
18 | import org.xmlbeam.annotation.XBDocURL;
19 | import org.xmlbeam.annotation.XBRead;
20 |
21 | @SuppressWarnings("javadoc")
22 | @XBDocURL("resource://DocumentWithNamespaces.xml")
23 | public interface NamespacedProjection {
24 |
25 | @XBRead("//withoutNamespace")
26 | String getElementContentWithoutNamespace();
27 |
28 | @XBRead("//p:withPrefix")
29 | String getElementContentWithPrefix();
30 |
31 | @XBRead("//d:defaultNS")
32 | String getElementWithDefaultNamespace();
33 |
34 | @XBRead("//withPrefix")
35 | String findElementContentWithPrefixOmittingNS();
36 |
37 | @XBRead("//defaultNS")
38 | String findElementWithDefaultNamespaceOmittingNS();
39 |
40 | @XBRead("//x:withPrefix")
41 | String findElementWithNonExistingPrefix();
42 | }
43 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/namespaces/create/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * @author sven
18 | *
19 | */
20 | package org.xmlbeam.tests.namespaces.create;
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/testsuite.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | String content öäüÖÄÜß
6 | 0
7 | 1
8 | 65536
9 | -1
10 | true
11 |
12 |
13 |
14 | a
15 | b
16 | c
17 |
18 |
19 |
20 |
21 | A
22 |
23 | A
24 | B
25 | C
26 |
27 |
28 |
29 | A2
30 |
31 | A2
32 | B2
33 | C2
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/util/intern/TestBase64Encoder.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2021 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tests.util.intern;
17 |
18 | import static org.junit.Assert.assertEquals;
19 |
20 | import org.junit.Test;
21 | import org.xmlbeam.util.Base64;
22 |
23 | /**
24 | * @author sven
25 | *
26 | */
27 | public class TestBase64Encoder {
28 |
29 | @SuppressWarnings("javadoc")
30 | @Test
31 | public void testBase64Encoder() {
32 | assertEquals("QUJDREU=",Base64.printBase64Binary("ABCDE".getBytes()));
33 | assertEquals("QUJDREVG",Base64.printBase64Binary("ABCDEF".getBytes()));
34 | assertEquals("QUJDREVGRw==",Base64.printBase64Binary("ABCDEFG".getBytes()));
35 | byte[] b=new byte[256];
36 | for (int i=0;i<256;++i)
37 | {
38 | b[i]=(byte)i;
39 | }
40 | assertEquals("AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==",Base64.printBase64Binary(b));
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/util/intern/TestDOMHelper.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tests.util.intern;
17 |
18 | import static org.junit.Assert.assertFalse;
19 | import static org.junit.Assert.assertTrue;
20 |
21 | import javax.xml.parsers.DocumentBuilderFactory;
22 |
23 | import org.junit.Before;
24 | import org.junit.Test;
25 | import org.w3c.dom.Document;
26 | import org.xmlbeam.annotation.XBRead;
27 | import org.xmlbeam.dom.DOMAccess;
28 | import org.xmlbeam.util.intern.DOMHelper;
29 |
30 | @SuppressWarnings("javadoc")
31 | public class TestDOMHelper {
32 |
33 | private Document document;
34 |
35 | @Before
36 | public void init() throws Exception {
37 | document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
38 | }
39 |
40 | public interface HelperProjection extends DOMAccess {
41 | @XBRead("{0}")
42 | HelperProjection selectXPath(String xpath);
43 | }
44 |
45 | @Test
46 | public void trivialNodeEquality() {
47 | assertTrue(DOMHelper.nodesAreEqual(null, null));
48 | assertTrue(DOMHelper.nodesAreEqual(document, document));
49 | assertFalse(DOMHelper.nodesAreEqual(document, null));
50 | assertFalse(DOMHelper.nodesAreEqual(null, document));
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/xpath/deletexml.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | secondContent1
6 |
7 |
8 | secondContent2
9 |
10 |
11 |
12 | firstlevelContent
13 |
14 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/xpath/testsetter.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Content
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/xpath/testsetter_expected.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Content
4 |
5 | Content
6 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tests/xpath/variables/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * Package for test cases that ensure the function of XPath variables.
18 | */
19 | package org.xmlbeam.tests.xpath.variables;
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/testutils/TestIOUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2017 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.testutils;
17 |
18 | import java.io.File;
19 | import java.io.FileInputStream;
20 | import java.io.IOException;
21 |
22 | import org.xmlbeam.util.IOHelper;
23 |
24 | /**
25 | *
26 | */
27 | public class TestIOUtils {
28 |
29 | /**
30 | * @param file
31 | * @return string content of file
32 | * @throws IOException
33 | */
34 | public static String file2String(File file) throws IOException {
35 | FileInputStream is = new FileInputStream(file);
36 | String string = IOHelper.inputStreamToString(is);
37 | is.close();
38 | return string;
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/Tutorial.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tutorial;
17 |
18 | /**
19 | * JUnit category to group all tutorial code.
20 | *
21 | * @author Sven Ewald
22 | */
23 | public interface Tutorial {
24 | }
25 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e01_weather/WeatherData.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e02_jenkins/model/Builder.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tutorial.e02_jenkins.model;
17 |
18 | import org.xmlbeam.annotation.XBRead;
19 | @SuppressWarnings("javadoc")
20 | //START SNIPPET: JenkinsBuilderInterface
21 | public interface Builder extends ModelElement {
22 |
23 | /**
24 | * Builder may invoke ant targets, maven goals or shell commands.
25 | * @return The builders task, whatever this element is.
26 | */
27 | @XBRead("child::targets | child::command")
28 | String getTargetsOrCommands();
29 |
30 | }
31 | //END SNIPPET: JenkinsBuilderInterface
32 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e02_jenkins/model/ModelElement.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tutorial.e02_jenkins.model;
17 |
18 | import org.xmlbeam.annotation.XBRead;
19 | @SuppressWarnings("javadoc")
20 | //START SNIPPET: JenkinsModelElementInterface
21 | public interface ModelElement {
22 |
23 | /**
24 | * Getter may use XPath functions.
25 | * @return Name of the XML Element which is projected to this object.
26 | */
27 | @XBRead("name()")
28 | String getName();
29 | }
30 | //END SNIPPET: JenkinsModelElementInterface
31 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e02_jenkins/model/Publisher.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tutorial.e02_jenkins.model;
17 |
18 | import org.xmlbeam.annotation.XBRead;
19 |
20 | @SuppressWarnings("javadoc")
21 | //START SNIPPET: JenkinsPublisherInterface
22 | public interface Publisher extends ModelElement{
23 |
24 | /**
25 | * The Plugin name is located in an attribute of the configuration element.
26 | * @return The plugin name which contributed this element.
27 | */
28 | @XBRead("@plugin")
29 | String getPlugin();
30 |
31 | }
32 | //END SNIPPET: JenkinsPublisherInterface
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e03_eclipse/EclipseFormatterConfigFile.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tutorial.e03_eclipse;
17 |
18 | import java.util.List;
19 |
20 | import org.xmlbeam.annotation.XBDocURL;
21 | import org.xmlbeam.annotation.XBRead;
22 |
23 | /**
24 | * We proceed with our examples to parameterized projections. Because
25 | * projections will be compiled and processed when used, there is no need to
26 | * keep them static. Instead give your getter method some parameters. They will
27 | * be applied as a {@lik MessageFormat} on the XBRead expression. (This is
28 | * possible on XBDocURL annotations, too).
29 | *
30 | * @author Sven Ewald
31 | */
32 | @SuppressWarnings("javadoc")
33 | //START SNIPPET: EclipseCodeFormatterConfig
34 | @XBDocURL("resource://eclipsecodeformatprofile.xml")
35 | public interface EclipseFormatterConfigFile {
36 |
37 | interface Setting {
38 |
39 | @XBRead("@id")
40 | String getName();
41 |
42 | @XBRead("@value")
43 | String getValue();
44 |
45 | }
46 |
47 | @XBRead("//profile/@name")
48 | List getProfileNames();
49 |
50 | @XBRead("//profiles/profile[@name=\"{0}\"]/setting")
51 | List getAllSettingsForProfile(String profileName);
52 |
53 | }
54 | //END SNIPPET: EclipseCodeFormatterConfig
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e04_maven/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | org.apache.maven
4 | maven
5 | 2.0
6 | jar
7 |
8 | Maven core
9 | This is just a basic example pom to demonstrate xmlbeam projection writing xml.
10 | http://maven.apache.org
11 |
12 |
13 |
14 | The Apache Software License, Version 2.0
15 | http://www.apache.org/licenses/LICENSE-2.0.txt
16 | repo
17 |
18 |
19 |
20 |
21 | http://svn.apache.org/viewcvs.cgi/maven
22 |
23 |
24 |
25 |
26 | some.group
27 | some.artifact
28 | 1.0
29 |
30 |
31 | org.apache.maven
32 | maven
33 | 3.8.1
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e06_xhtml/XHTML.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tutorial.e06_xhtml;
17 |
18 | import org.xmlbeam.annotation.XBWrite;
19 |
20 | /**
21 | * Finally we go the other way around. We create a new document and fill the content via this projection interface.
22 | *
23 | * @author Sven Ewald
24 | *
25 | */
26 | @SuppressWarnings("javadoc")
27 | //START SNIPPET:XHTML
28 | public interface XHTML {
29 |
30 | @XBWrite("/html/@xmlns")
31 | XHTML setRootNameSpace(String ns);
32 |
33 | @XBWrite("/html/@xml:lang")
34 | XHTML setRootLang(String lang);
35 |
36 | @XBWrite("/html/head/title")
37 | XHTML setTitle(String title);
38 |
39 | @XBWrite("/html/body")
40 | XHTML setBody(String body);
41 | }
42 | //END SNIPPET:XHTML
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e07_svg/svg.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e08_api_mimicry/Attribute.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tutorial.e08_api_mimicry;
17 |
18 | import org.xmlbeam.annotation.XBRead;
19 |
20 | @SuppressWarnings("javadoc")
21 | //START SNIPPET:Attribute
22 | public interface Attribute {
23 |
24 | @XBRead("name()")
25 | String getName();
26 |
27 | @XBRead(".")
28 | String getValue();
29 | }
30 | //END SNIPPET:Attribute
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e08_api_mimicry/Document.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tutorial.e08_api_mimicry;
17 |
18 | import org.xmlbeam.annotation.XBDocURL;
19 | import org.xmlbeam.annotation.XBRead;
20 | import org.xmlbeam.annotation.XBWrite;
21 |
22 | @SuppressWarnings("javadoc")
23 | @XBDocURL("resource://simple.xml")
24 | //START SNIPPET:Document
25 | public interface Document {
26 |
27 | @XBRead("/*")
28 | Element getRootElement();
29 |
30 | @XBWrite("/*")
31 | void setRootElement(Element rootElement);
32 |
33 | }
34 | //END SNIPPET:Document
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e08_api_mimicry/Element.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tutorial.e08_api_mimicry;
17 |
18 | import java.util.List;
19 |
20 | import org.xmlbeam.annotation.XBRead;
21 | import org.xmlbeam.annotation.XBValue;
22 | import org.xmlbeam.annotation.XBWrite;
23 | @SuppressWarnings("javadoc")
24 | //START SNIPPET:Element
25 | public interface Element {
26 |
27 | @XBRead(".")
28 | Element addAttribute(Attribute attribute);
29 |
30 | @XBWrite("@{1}")
31 | Element addAttribute(String name, @XBValue String value);
32 |
33 | @XBRead("@{0}")
34 | Attribute attribute(String name);
35 |
36 | @XBRead("count(@*)")
37 | int attributeCount();
38 |
39 | @XBRead("@*")
40 | List attributes();
41 |
42 | @XBRead("@{0}")
43 | String attributeValue(String attributeName);
44 |
45 | @XBRead("./{0}")
46 | Element element(String name);
47 |
48 | @XBRead("./*")
49 | List elements();
50 |
51 | @XBRead("name()")
52 | String getName();
53 |
54 | @XBRead(".")
55 | String getText();
56 |
57 | }
58 | //END SNIPPET:Element
59 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e08_api_mimicry/simple.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | ElementValue
4 |
5 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e09_dreambox/Event.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tutorial.e09_dreambox;
17 |
18 | import org.xmlbeam.annotation.XBRead;
19 | /**
20 | * @author Sven Ewald
21 | */
22 | @SuppressWarnings("javadoc")
23 | public interface Event {
24 |
25 | @XBRead("//e2eventid")
26 | String getID();
27 |
28 | @XBRead("//e2eventstart * 1000")
29 | long getStart();
30 |
31 | @XBRead("//e2eventduration div 60")
32 | long getDurationInMinutes();
33 |
34 | @XBRead("//e2eventcurrenttime")
35 | long getCurrentTime();
36 |
37 | @XBRead("//e2eventtitle")
38 | String getTitle();
39 |
40 | @XBRead("//e2eventdescription")
41 | String getDescription();
42 |
43 | @XBRead("//e2eventdescriptionextended")
44 | String getDescriptionExtended();
45 |
46 | @XBRead("//e2eventservicereference")
47 | String getServiceReference();
48 |
49 | @XBRead("//e2eventservicename")
50 | String getServiceName();
51 | }
52 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e09_dreambox/Movie.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tutorial.e09_dreambox;
17 |
18 | import org.xmlbeam.annotation.XBRead;
19 |
20 | @SuppressWarnings("javadoc")
21 | /**
22 | * @author Sven Ewald
23 | */
24 | public interface Movie {
25 |
26 | @XBRead("child::e2servicereference")
27 | String getServiceReference();
28 |
29 | @XBRead("child::e2time")
30 | long getTime();
31 |
32 | @XBRead("child::e2length")
33 | long getLength();
34 |
35 | @XBRead("child:e2filesize")
36 | long getFileSize();
37 |
38 | @XBRead("child::e2title")
39 | String getTitle();
40 |
41 | @XBRead("child::e2description")
42 | String getDescription();
43 |
44 | @XBRead("child::e2descriptionextended")
45 | String getDescriptionExtended();
46 |
47 | @XBRead("child::e2tags")
48 | String getTags();
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e09_dreambox/Service.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tutorial.e09_dreambox;
17 |
18 | import org.xmlbeam.annotation.XBRead;
19 |
20 | /**
21 | * @author Sven Ewald
22 | */
23 | @SuppressWarnings("javadoc")
24 | public interface Service {
25 |
26 | @XBRead("//e2servicereference")
27 | String getReference();
28 |
29 | @XBRead("e2servicename")
30 | String getName();
31 | }
32 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e10_wikipedia/ProgrammingLanguage.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tutorial.e10_wikipedia;
17 |
18 | import org.xmlbeam.annotation.XBDocURL;
19 | import org.xmlbeam.annotation.XBRead;
20 |
21 | @SuppressWarnings("javadoc")
22 | //START SNIPPET:ProgrammingLanguage
23 | @XBDocURL("http://en.wikipedia.org/wiki/{0}_(programming_language)")
24 | public interface ProgrammingLanguage {
25 |
26 |
27 | @XBRead("//b[1]")
28 | String getName();
29 |
30 | @XBRead("normalize-space(//td[../th = \"Designed by\"])")
31 | String getCreator();
32 |
33 | }
34 | //END SNIPPET:ProgrammingLanguage
35 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e10_wikipedia/TestWikiAccess.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tutorial.e10_wikipedia;
17 |
18 | import java.io.IOException;
19 |
20 | import org.junit.Test;
21 | import org.xmlbeam.XBProjector;
22 | import org.xmlbeam.tutorial.TutorialTestCase;
23 |
24 | //START SNIPPET: Tutorial10
25 |
26 | /* START SNIPPET: TutorialDescription
27 | ~~
28 | This tutorial demonstrates the expressiveness of XMLBeam projections.
29 | Four web pages about different programming languages will be fetched from Wikipedia and
30 | their creator will be extracted.
31 | * Shows a projection to HMTL Documents
32 | END SNIPPET: TutorialDescription */
33 | @SuppressWarnings("javadoc")
34 | //START SNIPPET: TestWikiAccess
35 | public class TestWikiAccess extends TutorialTestCase{
36 |
37 | final private String[] PROGRAMMING_LANGUAGES = new String[] { "Java", "C++", "C", "Scala" };
38 |
39 | @Test
40 | public void wikiIt() throws IOException {
41 | for (String name : PROGRAMMING_LANGUAGES) {
42 | ProgrammingLanguage lang = new XBProjector().io().fromURLAnnotation(ProgrammingLanguage.class,name);
43 | System.out.println(lang.getCreator() + " designed " + lang.getName());
44 | }
45 | }
46 | }
47 | //END SNIPPET: TestWikiAccess
48 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e11_freemind/MindMap.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tutorial.e11_freemind;
17 |
18 | import org.xmlbeam.annotation.XBDocURL;
19 | import org.xmlbeam.annotation.XBRead;
20 | @SuppressWarnings("javadoc")
21 | //START SNIPPET: MindMap
22 | @XBDocURL("resource://XMLBeam.mm")
23 | public interface MindMap {
24 |
25 | public interface Node {
26 | @XBRead("./node")
27 | Node[] getSubNodes();
28 |
29 | @XBRead("@TEXT")
30 | String getText();
31 | }
32 |
33 | @XBRead("/map/node")
34 | Node getRootNode();
35 |
36 | @XBRead("//node[@POSITION='left']")
37 | Node[] getLeftNodes();
38 |
39 | @XBRead("//node[@POSITION='right']")
40 | Node[] getRightNodes();
41 |
42 | @XBRead("count(descendant-or-self::node)")
43 | int getNodeCount();
44 |
45 | }
46 | //END SNIPPET: MindMap
47 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e12_xml3d/Xml3d.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tutorial.e12_xml3d;
17 |
18 | import org.xmlbeam.annotation.XBDocURL;
19 | import org.xmlbeam.annotation.XBRead;
20 | import org.xmlbeam.annotation.XBWrite;
21 | @SuppressWarnings("javadoc")
22 | //START SNIPPET: Xml3d
23 | @XBDocURL("resource://xml3d_template.html")
24 | public interface Xml3d {
25 |
26 | @XBRead("/html/body/xml3d/mesh/int[@name='index']")
27 | String getIndexes();
28 |
29 | @XBWrite("/html/body/xml3d/mesh/int[@name='index']")
30 | Xml3d setIndexes(String indexes);
31 |
32 | @XBRead("/html/body/xml3d/mesh/float3[@name='position']")
33 | String getPositions();
34 |
35 | @XBWrite("/html/body/xml3d/mesh/float3[@name='position']")
36 | Xml3d setPositions(String positions);
37 |
38 | @XBRead("/html/body/xml3d/mesh/float3[@name='normal']")
39 | String getNormals();
40 |
41 | @XBWrite("/html/body/xml3d/mesh/float3[@name='normal']")
42 | Xml3d setNormals(String normals);
43 | }
44 | //END SNIPPET: Xml3d
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e12_xml3d/xml3d_template.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | Click and drag to rotate the triangles
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e13_graphml/Edge.java:
--------------------------------------------------------------------------------
1 | /************************************************************************
2 | * *
3 | * DDDD SSSS AAA Daten- und Systemtechnik Aachen GmbH *
4 | * D D SS A A Pascalstrasse 28 *
5 | * D D SSS AAAAA 52076 Aachen-Oberforstbach, Germany *
6 | * D D SS A A Telefon: +49 (0)2408 / 9492-0 *
7 | * DDDD SSSS A A Telefax: +49 (0)2408 / 9492-92 *
8 | * *
9 | * *
10 | * (c) Copyright by DSA - all rights reserved *
11 | * *
12 | ************************************************************************
13 | *
14 | * Initial Creation:
15 | * Author se
16 | * Created on 12.04.2013
17 | *
18 | ************************************************************************/
19 | package org.xmlbeam.tutorial.e13_graphml;
20 |
21 | import org.xmlbeam.annotation.XBDocURL;
22 | import org.xmlbeam.annotation.XBRead;
23 | import org.xmlbeam.annotation.XBWrite;
24 | @SuppressWarnings("javadoc")
25 | //START SNIPPET: Edge
26 | @XBDocURL("resource://EdgeTemplate.xml")
27 | public interface Edge {
28 | @XBRead("/edge")
29 | Edge rootElement();
30 |
31 | @XBWrite("/g:edge/@id")
32 | Edge setID(String id);
33 |
34 | @XBWrite("/g:edge/@source")
35 | Edge setSource(String id);
36 |
37 | @XBWrite("/g:edge/@target")
38 | Edge setTarget(String id);
39 |
40 | @XBRead("/g:edge/@id")
41 | String getID();
42 |
43 | }
44 | //END SNIPPET: Edge
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e13_graphml/EdgeTemplate.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e13_graphml/GraphMLTemplate.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e13_graphml/Node.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 Sven Ewald
3 | *
4 | * This file is part of JSONBeam.
5 | *
6 | * JSONBeam is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, any
9 | * later version.
10 | *
11 | * JSONBeam is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with JSONBeam. If not, see .
18 | */
19 | package org.xmlbeam.tutorial.e13_graphml;
20 |
21 |
22 |
23 | import org.xmlbeam.annotation.XBDocURL;
24 | import org.xmlbeam.annotation.XBRead;
25 | import org.xmlbeam.annotation.XBWrite;
26 | @SuppressWarnings("javadoc")
27 | //START SNIPPET: Node
28 | @XBDocURL("resource://NodeTemplate.xml")
29 | public interface Node {
30 | @XBRead("/node")
31 | Node rootElement();
32 |
33 | @XBWrite("./@id")
34 | Node setID(String id);
35 |
36 | @XBWrite("./data/y:ShapeNode/y:Geometry/@height")
37 | Node setHeight(float h);
38 |
39 | @XBWrite("./data/y:ShapeNode/y:Geometry/@width")
40 | Node setWidth(float w);
41 |
42 | @XBWrite("./data/y:ShapeNode/y:Geometry/@x")
43 | Node setX(float x);
44 |
45 | @XBWrite("./data/y:ShapeNode/y:Geometry/@y")
46 | Node setY(float y);
47 |
48 | @XBWrite("./data/y:ShapeNode/y:NodeLabel")
49 | void setLabel(String string);
50 |
51 | @XBRead("./data/y:ShapeNode/y:NodeLabel")
52 | String getLabel();
53 |
54 | @XBRead("./@id")
55 | String getID();
56 |
57 | @XBRead("{0}")
58 | String xpath(String path);
59 | }
60 | //END SNIPPET: Edge
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e13_graphml/NodeTemplate.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
14 | data>
15 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e14_kml/Coordinate.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tutorial.e14_kml;
17 | @SuppressWarnings("javadoc")
18 | public class Coordinate {
19 |
20 | private Double x;
21 | private Double y;
22 |
23 | public Coordinate(Double x, Double y) {
24 | this.setX(x);
25 | this.setY(y);
26 | }
27 |
28 | public Double getY() {
29 | return y;
30 | }
31 |
32 | public void setY(Double y) {
33 | this.y = y;
34 | }
35 |
36 | public Double getX() {
37 | return x;
38 | }
39 |
40 | public void setX(Double x) {
41 | this.x = x;
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e14_kml/CoordinateList.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tutorial.e14_kml;
17 |
18 | import java.util.Iterator;
19 | import java.util.LinkedList;
20 | import java.util.List;
21 | @SuppressWarnings("javadoc")
22 | public class CoordinateList implements Iterable {
23 |
24 | private final List coordinates = new LinkedList();
25 |
26 | public CoordinateList(String data) {
27 | for (String s : data.trim().split("\\s+")) {
28 | if (s.isEmpty()) {
29 | continue;
30 | }
31 | Coordinate coordinate = new Coordinate(Double.parseDouble(s.split(",")[0]), Double.parseDouble(s.split(",")[1]));
32 | coordinates.add(coordinate);
33 | }
34 | }
35 |
36 | @Override
37 | public Iterator iterator() {
38 | return coordinates.iterator();
39 | }
40 |
41 | @Override
42 | public String toString() {
43 | StringBuilder s = new StringBuilder();
44 | for (Coordinate xy : this) {
45 | s.append(xy.getX()).append(",").append(xy.getY()).append(" ");
46 | }
47 | return s.toString().trim();
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e14_kml/KML.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tutorial.e14_kml;
17 |
18 | import org.xmlbeam.annotation.XBDocURL;
19 | import org.xmlbeam.annotation.XBRead;
20 | import org.xmlbeam.annotation.XBWrite;
21 |
22 | @SuppressWarnings("javadoc")
23 | //START SNIPPET: KML
24 | @XBDocURL("resource://polygon-simple.kml")
25 | public interface KML {
26 |
27 | @XBRead("/kml/Placemark/Polygon/outerBoundaryIs/LinearRing/coordinates")
28 | public CoordinateList getCoordinates();
29 |
30 | @XBWrite("/kml/Placemark/Polygon/outerBoundaryIs/LinearRing/coordinates")
31 | public KML setCoordinates(CoordinateList coordinates);
32 |
33 | }
34 | //END SNIPPET: KML
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e14_kml/polygon-simple.kml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Polygon with simple Region
5 |
10 |
11 |
12 | 128
13 |
14 |
15 | -34.85
16 | -34.97
17 | 138.64
18 | 138.56
19 |
20 |
21 |
22 |
23 |
24 |
25 | 138.64,-34.93 138.64,-34.94 138.63,-34.94 138.62,-34.94
26 | 138.62,-34.95 138.62,-34.96 138.63,-34.96 138.62,-34.96
27 | 138.61,-34.97 138.60,-34.97 138.59,-34.97 138.58,-34.97
28 | 138.57,-34.97 138.57,-34.96 138.57,-34.95 138.57,-34.95
29 | 138.57,-34.94 138.57,-34.93 138.57,-34.92 138.57,-34.92
30 | 138.57,-34.91 138.56,-34.91 138.56,-34.90 138.57,-34.90
31 | 138.57,-34.90 138.57,-34.89 138.57,-34.89 138.57,-34.89
32 | 138.56,-34.88 138.56,-34.88 138.56,-34.88 138.56,-34.88
33 | 138.57,-34.88 138.58,-34.87 138.58,-34.87 138.58,-34.86
34 | 138.58,-34.85 138.58,-34.85 138.60,-34.85 138.61,-34.85
35 | 138.63,-34.85 138.63,-34.85 138.64,-34.86 138.64,-34.87
36 | 138.64,-34.87 138.63,-34.87 138.63,-34.88 138.62,-34.88
37 | 138.62,-34.88 138.62,-34.89 138.62,-34.89 138.62,-34.89
38 | 138.63,-34.89 138.63,-34.90 138.64,-34.90 138.64,-34.90
39 | 138.64,-34.91 138.64,-34.91 138.64,-34.92 138.64,-34.92
40 | 138.64,-34.93 138.64,-34.93
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e15_plist/PList.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tutorial.e15_plist;
17 |
18 | import org.xmlbeam.annotation.XBDocURL;
19 | import org.xmlbeam.annotation.XBRead;
20 | @SuppressWarnings("javadoc")
21 | //START SNIPPET: PList
22 | @XBDocURL("resource://example.plist")
23 | public interface PList {
24 |
25 | @XBRead()
26 | String getAuthor();
27 |
28 | @XBRead()
29 | String[] getLines();
30 |
31 | @XBRead()
32 | int getBirthdate();
33 |
34 | }
35 | //END SNIPPET: PList
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e15_plist/example.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Author
8 | Charles Robert Darwin
9 | Lines
10 |
11 | A man who dares to waste one hour of time has not discovered the value of life.
12 | I have tried lately to read Shakespeare, and found it so intolerably dull that it nauseated me.
13 | I love fools' experiments. I am always making them.
14 |
15 | Birthdate
16 | 1809
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e16_schemaHandling/Vegetable.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tutorial.e16_schemaHandling;
17 |
18 | import org.xmlbeam.annotation.XBRead;
19 |
20 | @SuppressWarnings("javadoc")
21 | //START SNIPPET: SchemaHandling
22 | public interface Vegetable {
23 | @XBRead("@name")
24 | String getName();
25 |
26 | @XBRead("@color")
27 | String getColor();
28 | }
29 | //END SNIPPET: SchemaHandling
30 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e16_schemaHandling/Vegetables.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tutorial.e16_schemaHandling;
17 |
18 | import org.xmlbeam.annotation.XBDocURL;
19 | import org.xmlbeam.annotation.XBRead;
20 |
21 | @SuppressWarnings("javadoc")
22 | //START SNIPPET: SchemaHandling
23 | @XBDocURL("resource://vegetables.xml")
24 | public interface Vegetables {
25 | @XBRead("/xbdefaultns:Vegetables/xbdefaultns:Vegetable[@name='{0}']")
26 | Vegetable getVegetable(String name);
27 | }
28 | //END SNIPPET: SchemaHandling
29 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e16_schemaHandling/schema.xsd:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e16_schemaHandling/vegetables.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e17_svgTemplateInheritance/SVG.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.xmlbeam.tutorial.e17_svgTemplateInheritance;
17 |
18 | import java.util.List;
19 |
20 | import org.xmlbeam.annotation.XBDocURL;
21 | import org.xmlbeam.annotation.XBWrite;
22 |
23 | @SuppressWarnings("javadoc")
24 | @XBDocURL("resource://svg_document_template.svg")
25 | public interface SVG {
26 |
27 | public interface Shape {
28 | @XBWrite("./@x")
29 | Shape setX(int x);
30 |
31 | @XBWrite("./@y")
32 | Shape setY(int y);
33 | }
34 |
35 | @XBDocURL("resource://rect_template.svg")
36 | public interface Rect extends Shape {
37 | }
38 |
39 | @XBDocURL("resource://circle_template.svg")
40 | public interface Circle extends Shape {
41 | }
42 |
43 | @XBDocURL("resource://ellipse_template.svg")
44 | public interface Ellipse extends Shape {
45 | }
46 |
47 | @XBWrite("/svg/g/*")
48 | SVG setShapes(List shapes);
49 | }
50 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e17_svgTemplateInheritance/circle_template.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e17_svgTemplateInheritance/ellipse_template.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e17_svgTemplateInheritance/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 Sven Ewald
3 | *
4 | * This file is part of JSONBeam.
5 | *
6 | * JSONBeam is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, any
9 | * later version.
10 | *
11 | * JSONBeam is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with JSONBeam. If not, see .
18 | */
19 | package org.xmlbeam.tutorial.e17_svgTemplateInheritance;
20 |
21 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e17_svgTemplateInheritance/rect_template.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e17_svgTemplateInheritance/svg_document_template.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e27_cdlib/cdlib.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Empire Burlesque
4 | Bob Dylan
5 | USA
6 | Columbia
7 | 10.90
8 | 1985
9 |
10 |
11 | Hide your heart
12 | Bonnie Tyler
13 | UK
14 | CBS Records
15 | 9.90
16 | 1988
17 |
18 |
19 | Greatest Hits
20 | Dolly Parton
21 | USA
22 | RCA
23 | 9.90
24 | 1982
25 |
26 |
27 | Still got the blues
28 | Gary Moore
29 | UK
30 | Virgin records
31 | 10.20
32 | 1990
33 |
34 |
--------------------------------------------------------------------------------
/src/test/java/org/xmlbeam/tutorial/e27_cdlib/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 Sven Ewald
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * @author sven
18 | *
19 | */
20 | package org.xmlbeam.tutorial.e27_cdlib;
--------------------------------------------------------------------------------
/verify_signatures.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #version=`xpath pom.xml "/project/version/text()" 2>/dev/null | tail -1`
3 | version=$1
4 | echo checking version $version
5 | for type in -javadoc.jar -sources.jar .jar .pom ; do
6 | file="target/xmlprojector-$version$type"
7 | echo $file
8 | gpg --verify $file".asc" $file || exit 1
9 | done
--------------------------------------------------------------------------------