Stroika Library 3.0d25
 
Loading...
Searching...
No Matches
SOAP_EnvelopeSchema.cpp
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2026. All rights reserved
3 */
4#include "Stroika/Frameworks/StroikaPreComp.h"
5
6#include "Stroika/Foundation/Containers/Mapping.h"
9
11
12/*
13 * The SOAP 1.1 envelope schema, embedded.
14 *
15 * Its own translation unit so that a program which never validates never carries it: Stroika is a static library, so
16 * an object nothing references is not pulled from the archive at all - no linker flag, no pragma, nothing to get wrong
17 * on one toolchain and not another. That only holds while nothing ELSE in SOAP calls EnvelopeSchema: Options takes the
18 * schema a caller wants rather than a flag that would reach for this one, which is what keeps the reference out.
19 *
20 * The schema is http://schemas.xmlsoap.org/soap/envelope/ VERBATIM - Schemas/soap-envelope-1.1.xsd byte for byte,
21 * notice included, which its licence (the W3C Software License) requires travel with any copy; EnvelopeSchema corrects
22 * a copy of it as it compiles, unless asked for it as published. It imports and includes nothing, so it compiles with
23 * no Resource::Resolver.
24 *
25 * KEPT IN THE TREE rather than fetched at build time the way ThirdPartyComponents are (LGP 2026-10-13). That machinery
26 * is for versioned source that then gets built, and everything it fetches carries a configure feature flag so it can be
27 * swapped, disabled, or pointed at a system copy - none of which a frozen 2001 standards document of 6K has any use
28 * for: there is no later version to want, and never will be. Tests/34 keeps three third-party .xsd files the same way.
29 * The line is source-we-compile versus data-we-embed.
30 *
31 * Embedded as BYTES rather than written as a C++ string literal because that notice carries a copyright sign: MSVC is
32 * passed no /utf-8, so a literal of it would be read as cp1252 and the notice mangled on Windows alone.
33 *
34 * @todo the xxd rule in this directory's Makefile, and the .embed it generates, go away for #embed once every
35 * compiler Stroika supports has it - the file, and everything said above, stay as they are.
36 */
37// the embed too, not just the function: with no schema support this file has nothing to compile, and an unused array of 6K
38// would warn
39#if qStroika_Foundation_DataExchange_XML_SupportParsing and qStroika_Foundation_DataExchange_XML_SupportSchema and qStroika_Foundation_DataExchange_XML_SupportDOM
40namespace {
41 DISABLE_COMPILER_GCC_WARNING_START ("GCC diagnostic ignored \"-Wunused-variable\""); // warning suppression for Schemas_soap_envelope_1_1_xsd_len
42 constexpr
43#include "soap-envelope-1.1.xsd.embed"
44 DISABLE_COMPILER_GCC_WARNING_END ("GCC diagnostic ignored \"-Wunused-variable\"");
45}
46
47using namespace Stroika::Foundation;
49
50using namespace Stroika::Frameworks;
51using namespace Stroika::Frameworks::WebService;
52
53XML::Schema::Ptr SOAP::EnvelopeSchema (const XML::Options& o, bool allowEncodingStyleOnEnvelope)
54{
55 // compiled once per provider (libxml2's and Xerces') and allowEncodingStyleOnEnvelope, and kept; a schema keeps its XML
56 // library alive, so this may outlive the provider
58 auto compiled = sCompiled_.rwget ();
59 const pair<const XML::Providers::IXMLProvider*, bool> key{&o.GetProvider (), allowEncodingStyleOnEnvelope};
60 if (optional<XML::Schema::Ptr> s = compiled->Lookup (key)) {
61 return *s;
62 }
63 string xsd{reinterpret_cast<const char*> (Schemas_soap_envelope_1_1_xsd), std::size (Schemas_soap_envelope_1_1_xsd)};
64 if (allowEncodingStyleOnEnvelope) {
65 // the one correction: Envelope takes SOAP's own encodingStyle too - declared before its anyAttribute, as XSD orders them
66 static constexpr string_view kEnvelopeType_{"<xs:complexType name=\"Envelope\" >"sv};
67 static constexpr string_view kAnyAttribute_{"<xs:anyAttribute"sv};
68 const size_t envelopeType = xsd.find (kEnvelopeType_);
69 Assert (envelopeType != string::npos); // a published schema that had changed would land here first
70 const size_t envelopesAnyAttribute = xsd.find (kAnyAttribute_, envelopeType);
71 Assert (envelopesAnyAttribute != string::npos);
72 xsd.insert (envelopesAnyAttribute, "<xs:attribute ref=\"tns:encodingStyle\" />"sv);
73 }
74 XML::Schema::Ptr s = XML::Schema::New (Memory::BLOB{as_bytes (span{xsd})}, nullptr, o);
75 compiled->Add (key, s);
76 return s;
77}
78#endif
Wrap any object with Synchronized<> and it can be used similarly to the base type,...
nonvirtual WritableReference rwget()
get a read-write smart pointer to the underlying Synchronized<> object, holding the full lock the who...
How XML is read and written - for now, with which provider - taken last by each XML function (DOM::Do...