wStringconverter::prepareXmlToEmbed

Bereitet eine XML Datei (z.B. SVG) zum Einbetten in HTML vor (verfügbar ab CMS-Version 011.002.197.000)

Funktionsaufruf

String prepareXmlToEmbed(String str)

Parameter

str

XML-Zeichenkette

Hinweis
Beim Einsatz von Framework-Funktionen in eigenen Skripten beachten Sie bitte den Artikel "So verwenden Sie das PHP-Framework in eigenen Scripten".
Wenn Sie eine Funktion innerhalb einer Weblication® Seite z.B. über das PHP-Quelltext Element oder in einem XSL-Template über wsl:php einbinden, muss das Framework über die grid.php nicht mehr referenziert werden. Sofern nachfolgend PHP-Beispiele aufgeführt sind, ist dies entsprechend zu beachten.

Beispiel

Weblication SVG-Logo als XML-String eingebettet

Quelltext

<?php

  $strXml          
'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" id="logo_weblication_form" data-name="logo weblication form" width="596" height="220" viewBox="0 0 596 220">
  <defs>
    <style>
      .cls-1 {
        fill: #fff;
      }

      .cls-2 {
        fill: #0050a0;
      }

      .cls-3 {
        fill-rule: evenodd;
      }
    </style>
  </defs>
  <rect id="Form_3" data-name="Form 3" class="cls-1" width="596" height="220"/>
  <rect id="Form_2" data-name="Form 2" class="cls-2" x="66" y="66" width="88" height="88"/>
  <path id="_" data-name="®" class="cls-3" d="M546.873,116.979a3.1,3.1,0,0,0-.547-0.873,1.787,1.787,0,0,0,1.523-1.939q0-1.851-2.4-1.851h-2.582v6.824h1.642v-2.723h0.163l1.42,2.723h1.967Zm-2-1.658h-0.37V113.56h0.577a0.789,0.789,0,0,1,.976.784,0.965,0.965,0,0,1-1.183.977h0Zm2.751-3.752a4.9,4.9,0,0,1,2.4,4.241,4.716,4.716,0,0,1-.644,2.42,4.81,4.81,0,0,1-4.179,2.391,4.545,4.545,0,0,1-2.381-.666,4.891,4.891,0,0,1-1.753-1.792,4.8,4.8,0,0,1-.644-2.427,4.715,4.715,0,0,1,.651-2.428,4.922,4.922,0,0,1,1.738-1.761,4.556,4.556,0,0,1,2.389-.652A4.637,4.637,0,0,1,547.627,111.569Zm-5.073-2.058a6.752,6.752,0,0,0-2.19,1.458,6.881,6.881,0,0,0-1.464,2.176,6.626,6.626,0,0,0-.533,2.635,6.707,6.707,0,0,0,.91,3.449,6.581,6.581,0,0,0,2.478,2.443,6.871,6.871,0,0,0,3.446.888,6.967,6.967,0,0,0,5.947-3.383,6.511,6.511,0,0,0,.932-3.4,6.864,6.864,0,0,0-.518-2.664,6.708,6.708,0,0,0-1.457-2.184,6.486,6.486,0,0,0-2.2-1.443,7.224,7.224,0,0,0-2.707-.5A6.8,6.8,0,0,0,542.554,109.511Z"/>
  <path id="Weblication" class="cls-3" d="M227.785,108.733l-6.819,27.422q-0.793,3.047-1.554,7.68h-0.064a72.691,72.691,0,0,0-1.776-8.061l-7.643-27.041H202.19l-7.453,26.977a68.594,68.594,0,0,0-1.776,8.316H192.9a68.7,68.7,0,0,0-1.68-8.665l-6.756-26.628h-7.548L188.3,152.6h8.309L204,125.364a62.8,62.8,0,0,0,1.586-8.125h0.063a70.31,70.31,0,0,0,1.681,8.252l7.453,27.1H223.5l11.354-43.862h-7.072Zm33.333,38.276H248.242V137.9h12.274v-5.332H248.242v-8.252h12.876v-5.522H241.232v33.8h19.886v-5.586Zm33.651-9.664A7.668,7.668,0,0,0,290.2,134.6v-0.063a8.953,8.953,0,0,0,4.075-3.047,7.61,7.61,0,0,0,1.443-4.57,7.112,7.112,0,0,0-2.934-6.11q-2.934-2.142-9.277-2.142-2.252,0-3.916.016t-3.013.047q-1.349.033-2.554,0.048t-2.917.016v33.8q9.26,0.126,10.973.127a19.332,19.332,0,0,0,8.421-1.555,9.768,9.768,0,0,0,4.5-3.967,10.33,10.33,0,0,0,1.317-5.015A7.783,7.783,0,0,0,294.769,137.345Zm-8.437-5.65a10.211,10.211,0,0,1-5.55,1.286q-1.554,0-2.664-.095v-9.2q1.014-.03,1.855-0.047t2.173-.016q6.185,0,6.184,4.348A4.164,4.164,0,0,1,286.332,131.7Zm0.872,14.489a7.689,7.689,0,0,1-5.122,1.46,22.473,22.473,0,0,1-3.964-.254v-9.871q0.857-.063,3.013-0.063,7.77,0,7.77,4.856A4.855,4.855,0,0,1,287.2,146.184Zm37.5,0.286H313.069V118.794h-7.01v33.8h18.649V146.47Zm14.082-27.676h-7.009v33.8h7.009v-33.8Zm33.746,26.5a16.584,16.584,0,0,1-7.105,1.555,11.964,11.964,0,0,1-5.724-1.267,8.339,8.339,0,0,1-3.6-3.788,13.575,13.575,0,0,1-1.237-6.038,12.534,12.534,0,0,1,2.664-8.319,9.255,9.255,0,0,1,7.517-3.185,22.415,22.415,0,0,1,7.136,1.174l0.666-6.189a27.224,27.224,0,0,0-7.263-.889,19.586,19.586,0,0,0-10.165,2.46,15.073,15.073,0,0,0-6.089,6.554,20.754,20.754,0,0,0-1.951,9.045,19.752,19.752,0,0,0,1.871,8.919,12.84,12.84,0,0,0,5.614,5.729A19.3,19.3,0,0,0,364,153.039a27.008,27.008,0,0,0,9.1-1.5Zm25.721-26.5h-8.278L377.2,152.6h7.009l2.474-6.57h14.082l2.41,6.57h7.8Zm-9.895,22.153,3.647-9.553a53.775,53.775,0,0,0,1.681-5.269h0.064q0.919,3.048,1.744,5.332l3.52,9.49H388.362ZM436,118.794H410.278v5.967h9.356V152.6h7.009V124.761H436v-5.967Zm13.892,0h-7.01v33.8h7.01v-33.8Zm40.483,7.157a13.47,13.47,0,0,0-5.841-5.808,18.916,18.916,0,0,0-8.714-1.921,18.274,18.274,0,0,0-8.762,2.159,16.207,16.207,0,0,0-6.413,6.2,18.281,18.281,0,0,0-2.38,9.443,22.231,22.231,0,0,0,1.047,6.95,14.758,14.758,0,0,0,3.127,5.475,13.728,13.728,0,0,0,5.174,3.491,19.213,19.213,0,0,0,7.1,1.222,18.938,18.938,0,0,0,8.92-2.126,15.9,15.9,0,0,0,6.444-6.189,18.428,18.428,0,0,0,2.381-9.49A19.719,19.719,0,0,0,490.374,125.951Zm-8.24,18.131a9.329,9.329,0,0,1-7.045,2.9q-4.686,0-7.013-3.2a13.746,13.746,0,0,1-2.328-8.292,13.044,13.044,0,0,1,1.314-6,9.054,9.054,0,0,1,3.531-3.861,9.382,9.382,0,0,1,4.781-1.282,8.723,8.723,0,0,1,6.966,2.975q2.564,2.976,2.565,8.514Q484.905,141.186,482.134,144.082Zm49.678-25.288h-6.818l0.063,14.885q0,6.57.19,9.744h-0.063a65.3,65.3,0,0,0-3.711-6.634l-11.354-17.995h-9.356v33.8h6.819l-0.064-17.678q0-4.285-.19-7.078h0.063a48.959,48.959,0,0,0,3.457,6.411L522.456,152.6h9.356v-33.8Z"/>
</svg>'
;
  
$strXmlPrepared  wStringconverter::prepareXmlToEmbed($strXml);
  print 
$strXmlPrepared;

?>

Ergebnis

Die Funktion löscht diverse Angaben wie Doctype, Prolog und Processing Instructions, welche ggf. sicherheitsrelevant sein können.
In jedem Fall sollte die Ausgabe individuell geprüft werden, um hinsichtlich Sicherheitsaspekt eine optimale Ausgabe zu erhalten.

 

Entwicklerbereich Weblication® CMS - © Scholl Communications AG