### CLI Mode Setup Source: https://github.com/schemaorg/schemarama/blob/main/core/README.md Command to install project dependencies when using Schemarama in CLI mode. ```bash npm install ``` -------------------------------- ### Install Python Server Prerequisites Source: https://github.com/schemaorg/schemarama/blob/main/demo/README.md Command to install the necessary Python packages for the sample server included in the demo. This is a prerequisite for running the Python-based server component. ```bash pip3 install -r requirements.txt ``` -------------------------------- ### Schema.org CreativeWork Example Source: https://github.com/schemaorg/schemarama/blob/main/core/test/data/tests/CreativeWork1.txt An example of a CreativeWork defined using Schema.org vocabulary. This snippet demonstrates basic JSON-LD structure for describing creative works. ```json { "@context": "http://schema.org/", "@type": "CreativeWork", "description": "test1-description" } ``` -------------------------------- ### Webpack Bundling Commands Source: https://github.com/schemaorg/schemarama/blob/main/core/README.md Instructions for bundling the Schemarama module for browser usage using webpack. This involves installing dependencies and running the webpack command to generate different bundle files. ```bash npm install npx webpack --config webpack.config.js ``` -------------------------------- ### JSON-LD Schema.org Book Example Source: https://github.com/schemaorg/schemarama/blob/main/pretty-markup/demo.html This snippet demonstrates a JSON-LD structure for a 'Book' entity, including its author, offer details, and associated library. It adheres to the Schema.org vocabulary for structured data markup. ```JSON-LD { "@context": "https://schema.org/", "@id": "#record", "@type": "Book", "additionalType": "Product", "name": "Le concerto", "author": "Ferchault, Guy", "offers":{ "@type": "Offer", "availability": "https://schema.org/InStock", "serialNumber": "CONC91000937", "sku": "780 R2", "offeredBy": { "@type": "Library", "@id": "http://library.anytown.gov.uk", "name": "Anytown City Library" }, "businessFunction": "http://purl.org/goodrelations/v1#LeaseOut", "itemOffered": "#record" } } ``` -------------------------------- ### ShEx and SHACL Validation with Schemarama Source: https://github.com/schemaorg/schemarama/blob/main/core/README.md Provides examples for validating structured data against ShEx and SHACL shapes using Schemarama's respective validators. Both validators accept shapes and data, with ShEx requiring a start shape and SHACL inferring targets. They return validation reports containing failures. ```javascript const ShexValidator = require('./schemarama/shexValidator').Validator; const annotations = { description: 'http://www.w3.org/2000/01/rdf-schema#comment', severity: 'http://www.w3.org/2000/01/rdf-schema#label' } // shapes - JSON object with shapes in ShExJ format const validator = new ShexValidator(shapes, {annotations: annotations}); const startShape = 'http://schema.org/validation#ValidSchemaThing' // data - string or n3.js Store, that should be validated validator.validate(data, startShape, {baseUrl: 'http://example.org/test'}) .then(report => report.failures.forEach(failure => console.log(failure))); ``` ```javascript const ShaclValidator = require('./schemarama/shaclValidator').Validator; const annotations = { description: 'http://www.w3.org/2000/01/rdf-schema#comment', severity: 'http://www.w3.org/2000/01/rdf-schema#label' } // shapes - JSON object with shapes in ShEx format const validator = new ShaclValidator(shapes, {annotations: annotations}); // data - string or n3.js Store, that should be validated validator.validate(data, {baseUrl: 'http://example.org/test'}) .then(report => report.failures.forEach(failure => console.log(failure))); ``` -------------------------------- ### Schema.org JSON-LD Thing Example Source: https://github.com/schemaorg/schemarama/blob/main/core/test/data/tests/Thing1.txt This snippet demonstrates a basic JSON-LD structure for defining a schema.org Thing. It includes the required '@context' and '@type' properties, along with a custom 'description'. This format is commonly used for structured data on the web. ```json { "@context": "http://schema.org/", "@type": "Thing", "description": "test1-description" } ``` -------------------------------- ### Schema.org Thing Example Source: https://github.com/schemaorg/schemarama/blob/main/core/test/data/tests/Thing4.txt This snippet demonstrates a basic JSON-LD object conforming to Schema.org vocabulary. It defines an entity as a 'Thing' with properties for 'name' and 'identifier'. This structure is commonly used for semantic web data and SEO. ```json { "@context": "https://schema.org/", "@type": "Thing", "name": "test1", "identifier": "AAAA" } ``` -------------------------------- ### Build and Run with Docker Source: https://github.com/schemaorg/schemarama/blob/main/demo/README.md Instructions for building the Docker image and running the application as a container. This allows for easy deployment and execution of the schema checker. ```docker docker build -t scc . docker run -p 5000:5000 scc ``` -------------------------------- ### Python Project Dependencies Source: https://github.com/schemaorg/schemarama/blob/main/demo/requirements.txt This snippet details the Python packages and their version specifiers required to set up and run the SchemaRama project. It includes web framework, CORS handling, web scraping, and browser automation libraries. ```Python Flask~=2.2.2 Flask-Cors===3.0.9 selenium-wire==2.1.2 chromedriver-binary==98.0.4758.80 beautifulsoup4~=4.10.0 ``` -------------------------------- ### Parse Data with Node CLI Source: https://github.com/schemaorg/schemarama/blob/main/core/README.md Parses input data files into various RDF formats. It requires the path to the input file and supports specifying an output file path or printing to the console. Users can also select the desired output format. ```cli node cli --parse **Required arguments:** --input - path to the input file. **Optional arguments:** --output - path to the output file. If not specified, output will be printed to the console. --format - one of the output formats. Available formats: nquads|ntriples|turtle|trig. 'nquads' is used by default. ``` -------------------------------- ### Schema.org Thing Entity Source: https://github.com/schemaorg/schemarama/blob/main/core/test/data/tests/Thing3.txt Represents a basic 'Thing' entity using Schema.org vocabulary. Includes properties like name, description, and identifier. ```json { "@context": "https://schema.org/", "@id": "http://example.org/", "@type": "Thing", "name": "test1", "description": "test1-description", "identifier": "AAAA" } ``` -------------------------------- ### Customize CSS Color Scheme Source: https://github.com/schemaorg/schemarama/blob/main/demo/README.md Demonstrates how to change the color scheme of the demo website by modifying the :root block in scc.css. This allows for visual customization of the application's appearance. ```css :root { --main: #f188cc; --main-transparent: rgba(241, 136, 204, 0.7); --background: #fafafa; } ``` -------------------------------- ### Parse Structured Data in JavaScript Source: https://github.com/schemaorg/schemarama/blob/main/core/README.md Demonstrates parsing structured data (JSON-LD, Microdata, RDFa, NQuads) using the Schemarama library. Each parsing function expects data as a string and a baseUrl, returning a parsed n3.Store. ```javascript const store = await parseJsonLd(data, baseUrl); ``` -------------------------------- ### Pretty Markup Generation and Display Source: https://github.com/schemaorg/schemarama/blob/main/pretty-markup/README.md Demonstrates how to generate and display structured data in a pretty, ladder-like format. It includes functions to render the data as HTML elements appended to a div or as plain text in a textarea. Both methods take the structured data as a string input. ```javascript /** * @param {string} data - string representation of the structured data */ async function addPrettyMarkup(data) { const prettyMarkupDiv = document.getElementById('pretty-markup'); const elements = await prettyMarkupHtml(data); for (const el of elements) { prettyMarkupDiv.appendChild(el); } } ``` ```javascript /** * @param {string} data - string representation of the structured data */ async function addPrettyMarkup(data) { const prettyMarkupTextarea = document.getElementById('text-pretty-markup'); prettyMarkupTextarea.value = await prettyMarkupText(data); } ``` -------------------------------- ### Jinja2 Template Structure Source: https://github.com/schemaorg/schemarama/blob/main/demo/templates/scc.html This snippet represents the Jinja2 template file structure for the Schemaorg Schemarama project. It defines blocks for content, styles, scripts, and header controls, indicating a templated web page layout. ```Jinja2 {% extends 'base.html' %} {% block styles %} {% endblock %} {% block scripts %} {% endblock %} {% block header_controls %} [Shapes](shapes.html) Validation language ShEx SHACL {% endblock %} {% block content %} ![validate]({{ url_for('static', filename='images/icons/play_arrow.svg')[1:] }}) ![remote url]({{ url_for('static', filename='images/icons/world.svg')[1:] }}) Load Show tests Hierarchy {% endblock %} ``` -------------------------------- ### Schemaorg Schemarama JSON-LD Schema Source: https://github.com/schemaorg/schemarama/blob/main/core/test/data/tests/Thing2.txt This snippet defines a basic entity using the Schema.org vocabulary. It specifies the context, type, name, and description of the entity. This format is commonly used for structured data on the web. ```APIDOC { "@context": "http://schema.org/", "@type": "Thing", "name": "test1", "description": "test1-description" } ``` -------------------------------- ### Validate Data with SHACL using Node CLI Source: https://github.com/schemaorg/schemarama/blob/main/core/README.md Validates input data files against a specified SHACL shapes graph. This command requires the SHACL shapes file path and the input data file path. Optional arguments include output file, base URI, annotations, and additional triples for subclassing. ```cli node cli --validate **Required arguments:** --shacl - path to SHACL shapes. Could be either local or URL --input - path to the input file. **Optional arguments:** --output - path to the output file. If not specified, output will be printed to the console. --base - base data URI (@id). If not specified, random URI will be used. --annotations - path to the annotation correspondence file, in JSON format, where keys are keys in the failure report object and values are annotation predicates. If not specified, annotations will be ignored. --subclasses - additional triples that should be added to data for every validation. Originally used for adding schema.org subclasses structure to the data. ``` -------------------------------- ### Validate Data with ShEx using Node CLI Source: https://github.com/schemaorg/schemarama/blob/main/core/README.md Validates input data files against a specified ShEx schema. This command requires the ShEx schema file path, the input data file path, and the target shape URI. Optional arguments include output file, base URI, and annotation mapping. ```cli node cli --validate **Required arguments:** --shex - path to ShEx shapes. Could be either local or URL --input - path to the input file. --target - target shape, e.g. http://example.org/shex#Thing. **Optional arguments:** --output - path to the output file. If not specified, output will be printed to the console. --base - base data URI (@id). If not specified, random URI will be used. --annotations - path to the annotation correspondence file, in JSON format, where keys are keys in the failure report object and values are annotation predicates. If not specified, annotations will be ignored. ``` -------------------------------- ### JSON-LD API Implementation and @preserve Removal Source: https://github.com/schemaorg/schemarama/blob/main/core/dist/schemarama.bundle.min.js.LICENSE.txt This snippet describes a JavaScript implementation of the JSON-LD API. It includes a function designed to remove '@preserve' keywords from the expanded result of framing operations, which is useful for cleaning up processed data. The implementation is licensed under the BSD 3-Clause License. ```javascript /** * A JavaScript implementation of the JSON-LD API. * * @author Dave Longley * * @license BSD 3-Clause License * Copyright (c) 2011-2022 Digital Bazaar, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Digital Bazaar, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** * Removes the @preserve keywords from expanded result of framing. * * @param input the framed, framed output. * @param options the framing options used. * * @return the resulting output. */ // disallow aliasing @context and @preserve // remove @preserve // remove @preserve from results ``` -------------------------------- ### Schema.org Property Validation Messages Source: https://github.com/schemaorg/schemarama/blob/main/core/test/data/utils/temp.txt This section outlines common validation messages encountered when validating schema.org data. It details the property being validated, the specific issue or message, the expected schema shape, and the severity of the validation result. ```APIDOC SchemaOrgValidationMessage: property: string - URI of the schema.org property being validated. message: string - Description of the validation issue. shape: string - URI of the expected schema shape or type. severity: "warning" | "error" - The severity level of the validation result. description: string (optional) - Additional context or explanation for the validation rule, e.g., 'Description is required for SomeProduct'. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.