我的xml看起来像这样:
...
<ImageRegion id="r0">
<Coords points="0,0 0,523 1365,523 1365,892 2048,892 2048,377 92,377 2048,377 2048,0"/>
</ImageRegion>
<TextRegion id="r2" type="caption">
<Coords points="1021,81 1021,182 40,182 40,81"/>
<TextEquiv conf="0.63228">
<Unicode>Lorem Ipsum</Unicode>
</TextEquiv>
</TextRegion>
...坐标点为区域(可以是任何类型的多边形,通常是矩形)的所有点提供x,y轴。有多个img和文本区域。
我想编写xslt (或任何东西),以获得与xml相同的html布局,但我不能理解。
Edit1:我正在使用png-img生成xml。我基本上想把img转换成html。我有cmpny工具,可以生成OCR和其他东西。我需要生成一个布局,指定text/imgs的位置。

如img中所示,标记的区域在XML文件中表示。我想在HTML页面中创建相同的布局。
发布于 2020-03-09 17:34:36
因此,我编写了一个python脚本来读取xml并生成html。
html如下所示:
<svg>
<g id="r1" class="img">
<polygon points="31,1757 30,3131 2017,3131 2018,1757"
style="fill:rgb(121,0,121);stroke-width:3; stroke:rgb(0,0,0);stroke-opacity:0.5;opacity:0.5">
</polygon>
</g>
<g id="r2" class="text">
<text x="530.5" y="131.5" fill="black" text-anchor="middle" alignment-baseline style="font-size: 20px;">Lorem Ipsum
</text>
<polygon points="1021,81 1021,182 40,182 40,81"
style="fill:rgb(50,50,121);stroke-width:3; stroke:rgb(0,0,0); stroke-opacity:0.5;opacity:0.5">
</polygon>
</g>
</svg>https://stackoverflow.com/questions/60563419
复制相似问题