Re: Parse stylesheet from a string (in memory) instead of from a file?

Christian Ceelen via xslt <[email protected]> Thu, 18 Nov 2021 10:18:51 +0100
Newsgroups gmane.comp.gnome.lib.xslt
Message-ID <CA+a8X8KxG-5MMGDmEJ153+ugaeWKB-3oxr+JAhPy1JGDJUgL-Q@mail.gmail.com>
--===============9136584313167695222==
Content-Type: multipart/alternative; boundary="00000000000040c44205d10ca69f"

--00000000000040c44205d10ca69f
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi Leif,

I had to solve this once before. My solution had then several step:
- use xmlReadMemory from libxml2 to read the XML from memory. this creates
an xmlDocPtr
- use xmlDocGetRootElement to get the root xmlNodePtr
- use xsltParseStylesheetDoc from libxslt to create the xsltStylesheetPtr
- use xsltApplyStylesheet with the the stylesheet and an xmlDocPtr to
convert.

This worked quite well in my case.

Best regards,
Christian

On Wed, Nov 17, 2021 at 6:44 PM Bloomquist, Leif via xslt <[email protected]>
wrote:

> Hi all,
>
>
>
> I=E2=80=99m porting an application that uses libxml/libxslt to an embedde=
d
> platform that has no filesystem.
>
>
>
> Accordingly, I=E2=80=99m trying to find (and hopefully not have to write)=
 an
> equivalent to xsltParseStylesheetFile() that accepts a string
> representation of the stylesheet, instead of a filename/URI pointing to
> it.  Coming up blank.
>
>
>
> For the schema file, I was able to simply replace xmlSchemaNewParserCtxt(=
)
> with xmlSchemaNewMemParserCtxt() =E2=80=93 is there an equivalent in libx=
slt that
> I=E2=80=99m overlooking?
>
>
>
> I=E2=80=99m also willing to accept that there is a better approach that I=
 haven=E2=80=99t
> considered : - )
>
>
>
> Any help appreciated.
>
>
>
> Thanks
>
> -Leif
>
> The information transmitted by and/or attached to this email is intended
> only for the person or entity to which it is addressed. This email and an=
y
> attachments may contain proprietary, confidential and/or privileged
> material. If you are not the intended recipient of this message, be aware
> that any use, review, retransmission, distribution, reproduction or any
> action taken in reliance upon this message is strictly prohibited. If you
> received this in error, please contact the sender and delete the material
> from all computers.
>
> Les renseignements transmis par ou joints au pr=C3=A9sent courrier =C3=A9=
lectronique
> sont destin=C3=A9s uniquement =C3=A0 la personne ou =C3=A0 l'entit=C3=A9 =
=C3=A0 laquelle ils sont
> adress=C3=A9s. Le pr=C3=A9sent courrier =C3=A9lectronique et toute pi=C3=
=A8ce jointe peuvent
> contenir des renseignements exclusifs, confidentiels ou privil=C3=A9gi=C3=
=A9s. Si
> vous n'=C3=AAtes pas le destinataire de ce message, veuillez noter que to=
ute
> utilisation, r=C3=A9vision, retransmission, distribution, reproduction ou=
 toute
> action entreprise sur la base de ce message est strictement interdite. Si
> vous avez re=C3=A7u ce message par erreur, veuillez communiquer avec
> l'exp=C3=A9diteur et supprimer le contenu de tous les ordinateurs.
> _______________________________________________
> xslt mailing list, project page http://xmlsoft.org/XSLT/
> [email protected]
> https://mail.gnome.org/mailman/listinfo/xslt
>

--00000000000040c44205d10ca69f
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hi Leif,<div><br></div><div>I had to solve this once befor=
e. My solution had then several step:</div><div>- use=C2=A0xmlReadMemory fr=
om libxml2 to read the XML from memory. this creates an xmlDocPtr<br></div>=
<div>- use xmlDocGetRootElement to get the root xmlNodePtr</div><div>- use=
=C2=A0xsltParseStylesheetDoc from libxslt to create the=C2=A0xsltStylesheet=
Ptr</div><div>- use=C2=A0xsltApplyStylesheet with the the stylesheet and an=
 xmlDocPtr to convert.</div><div><br></div><div>This worked quite well in m=
y case.</div><div><br></div><div>Best regards,</div><div>Christian</div></d=
iv><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On =
Wed, Nov 17, 2021 at 6:44 PM Bloomquist, Leif via xslt &lt;<a href=3D"mailt=
o:[email protected]">[email protected]</a>&gt; wrote:<br></div><blockquote class=
=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rg=
b(204,204,204);padding-left:1ex">





<div lang=3D"EN-CA">
<div class=3D"gmail-m_-1634440420729492326WordSection1">
<p class=3D"MsoNormal">Hi all,<u></u><u></u></p>
<p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p>
<p class=3D"MsoNormal">I=E2=80=99m porting an application that uses libxml/=
libxslt to an embedded platform that has no filesystem.<u></u><u></u></p>
<p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p>
<p class=3D"MsoNormal">Accordingly, I=E2=80=99m trying to find (and hopeful=
ly not have to write) an equivalent to xsltParseStylesheetFile() that accep=
ts a string representation of the stylesheet, instead of a filename/URI poi=
nting to it.=C2=A0 Coming up blank.<u></u><u></u></p>
<p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p>
<p class=3D"MsoNormal">For the schema file, I was able to simply replace xm=
lSchemaNewParserCtxt() with xmlSchemaNewMemParserCtxt() =E2=80=93 is there =
an equivalent in libxslt that I=E2=80=99m overlooking?<u></u><u></u></p>
<p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p>
<p class=3D"MsoNormal">I=E2=80=99m also willing to accept that there is a b=
etter approach that I haven=E2=80=99t considered : - )<u></u><u></u></p>
<p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p>
<p class=3D"MsoNormal">Any help appreciated.<u></u><u></u></p>
<p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p>
<p class=3D"MsoNormal">Thanks<u></u><u></u></p>
<p class=3D"MsoNormal">-Leif<u></u><u></u></p>
</div>
<div></div>
<p style=3D"font-size:11pt;line-height:10pt;font-family:&quot;Calibri Light=
&quot;">The information transmitted by and/or attached to this email is int=
ended only for the person or entity to which it is addressed. This email an=
d any attachments may contain proprietary, confidential
 and/or privileged material. If you are not the intended recipient of this =
message, be aware that any use, review, retransmission, distribution, repro=
duction or any action taken in reliance upon this message is strictly prohi=
bited. If you received this in error,
 please contact the sender and delete the material from all computers.<br>
<br>
Les renseignements transmis par ou joints au pr=C3=A9sent courrier =C3=A9le=
ctronique sont destin=C3=A9s uniquement =C3=A0 la personne ou =C3=A0 l&#39;=
entit=C3=A9 =C3=A0 laquelle ils sont adress=C3=A9s. Le pr=C3=A9sent courrie=
r =C3=A9lectronique et toute pi=C3=A8ce jointe peuvent contenir des renseig=
nements exclusifs,
 confidentiels ou privil=C3=A9gi=C3=A9s. Si vous n&#39;=C3=AAtes pas le des=
tinataire de ce message, veuillez noter que toute utilisation, r=C3=A9visio=
n, retransmission, distribution, reproduction ou toute action entreprise su=
r la base de ce message est strictement interdite. Si vous
 avez re=C3=A7u ce message par erreur, veuillez communiquer avec l&#39;exp=
=C3=A9diteur et supprimer le contenu de tous les ordinateurs.
</p>
<div></div>
</div>

_______________________________________________<br>
xslt mailing list, project page <a href=3D"http://xmlsoft.org/XSLT/" rel=3D=
"noreferrer" target=3D"_blank">http://xmlsoft.org/XSLT/</a><br>
<a href=3D"mailto:[email protected]" target=3D"_blank">[email protected]</a><br>
<a href=3D"https://mail.gnome.org/mailman/listinfo/xslt" rel=3D"noreferrer"=
 target=3D"_blank">https://mail.gnome.org/mailman/listinfo/xslt</a><br>
</blockquote></div>

--00000000000040c44205d10ca69f--

--===============9136584313167695222==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
xslt mailing list, project page http://xmlsoft.org/XSLT/
[email protected]
https://mail.gnome.org/mailman/listinfo/xslt

--===============9136584313167695222==--