POV-Ray : Newsgroups : povray.advanced-users : POVRay and XML : Re: POVRay and XML Server Time
29 Jul 2024 00:25:09 EDT (-0400)
  Re: POVRay and XML  
From: Bernd Fuhrmann
Date: 1 Jan 2005 11:27:10
Message: <41d6cf5e$1@news.povray.org>
Thorsten Froehlich wrote:
> In article <41d6c310$1@news.povray.org> , Bernd Fuhrmann 
> <Sil### [at] gmxde>  wrote:
> 
> 
>>No I won't. Its quite a task to write such a XSLT.
> 
> 
> Exactly that was my point ;-)
> 
> 
>>I have never worked
>>with X3D. It would take me weeks to learn X3D just to proove that it is
>>possible.
> 
> 
> Well, the only real difference is that there are no commas (well, they are
> optional in VRML, they are just like spaces) and no < > around vectors, and
> X3D keeps all coordinates in a *single* string.  It takes almost nothing to
> transform a classic VRML-style X3D mesh to POV-Ray (one can do it with a
> simple regular expression), but to transform the same X3D XML lots of manual
> tweaking is needed to just *remove* redundant XML syntax that serves no
> useful purpose at all!

I just wrote a little demo XSLT that puts commas where once were spaces 
in transform/translation attributes and adds < and > to the beginning 
and end. If you want anything more complex please send me an example 
what transformation you want. Btw: I'm not a very good XSLT programmer. 
I just use it for the creation of my small private webpage. So don't 
expect me to write complex parsers that would take a pro months.

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet	version="2.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns=""
 >

<xsl:output method="xml" encoding="iso-8859-1"/>

<xsl:template match="*|@*|text()|processing-instruction()">
<xsl:copy>
<xsl:apply-templates select="*|@*|text()|processing-instruction()"/>
</xsl:copy>
</xsl:template>

<xsl:template match="Transform">
<Transform>
<xsl:attribute name="translation"><<xsl:analyze-string 
select="@translation" regex=" +">
<xsl:matching-substring>,</xsl:matching-substring>
<xsl:non-matching-substring><xsl:value-of 
select="."/></xsl:non-matching-substring>
</xsl:analyze-string>></xsl:attribute>
</Transform>
</xsl:template>
</xsl:stylesheet>

Tested with this input:
---
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN"

"http://www.web3d.org/specifications/x3d-3.0.dtd">

<X3D profile='Immersive' 
xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance'

xsd:noNamespaceSchemaLocation='http://www.web3d.org/specifications/x3d-3.0.xsd'>
<head>
<meta name='filename' content='Figure02.1Hut.x3d'/>
<meta name='author' content='The VRML 2.0 Sourcebook, Copyright [1997] 
By Andrea L.

Ames, David R. Nadeau, and John L. Moreland'/>
<meta name='translator' content='Don Brutzman'/>
<meta name='created' content='6 August 2000'/>
<meta name='revised' content='9 July 2003'/>
<meta name='description' content='Your first VRML world - a brown hut.'/>
<meta name='url'

content='http://www.web3d.org/x3d/content/examples/Vrml2.0Sourcebook/Chapter02-Introdu

ction/Figure02.1Hut.x3d'/>
<meta name='generator' content='X3D-Edit,

http://www.web3d.org/x3d/content/README.X3D-Edit.html'/>
</head>
<!--
Index for DEF node: BROWN
-->
<Scene>
<!-- This NavigationInfo node is added to many scenes, making 
examination of objects

easier -->
<NavigationInfo type='"EXAMINE" "ANY"'/>
<Group>
<Shape>
<Appearance DEF='BROWN'>
<Material diffuseColor='0.8 0.6 0.3'/>
</Appearance>
<!-- Default Cylinder height=2, centered about origin -->
<Cylinder radius='2'/>
</Shape>
<Transform translation='0 2 0'>
<Shape>
<Appearance USE='BROWN'/>
<!-- Default Cone height=2, centered about local origin -->
<Cone bottomRadius='2.5'/>
</Shape>
</Transform>
</Group>
</Scene>
</X3D>
---
[Taken from 
http://www.web3d.org/x3d/content/examples/Vrml2.0Sourcebook/Chapter02-Introduction/_pages/page01.html]
I know this is not what you wanted. But this script could be extended so 
that it might do things more complete. I do not yet know enough about 
X3D to write anything that actually makes sense. Please provide an 
example if you are interested.

Regards,
Bernd Fuhrmann


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.