关于xml命名空间的——xmlns:f="http://www.name.com.cn/sub",一些疑问

本文深入解析了《flashActionScript3殿堂之路》中的Namespace概念,包括其属性prefix和uri的作用,以及在不同场景下如何合理地为Namespace赋值。通过实例讲解,帮助开发者更好地理解和运用Namespace来组织代码,提升代码可读性和维护性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在《flash ActionScript 3 殿堂之路》page132,page133,有以下这段话,可以解决一些疑问

     page132

    namespace类对象只有两个属性:prefix和uri。prefix,即前缀,在处理xml时才会用到。URI属性是一个字符串类型,记录着namespace对象的URI。URI是The Uniform Resource Identifier (统一资源定位符)的简写。由于namespace的toString()和valueOf()都被重写成了返回URI属性,因此我们可以将URI看成namespace对象的名字。


page133

     什么时候明确赋值?什么时候让系统帮我们生成呢?在一般情况下,使用系统默认生成的URI值就可以了。如果我们要对外发布代码(往往是类库),并且希望通过命名空间的URI值提示一些额外信息,那么可以考虑明确赋值。  比如,在Flex 2 中mx_internal  的值中含有2006字样,我们立刻就可以判断trace(ma_internal)这段代码使用的是Flex 2时期的类库。当Flex 3发布后,mx_internal的值又会有其他变化(比如变成2007),这样可以起到一个  控制版本的作用。而系统生成值就没有这些特色。

String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<scb:SCBML xmlns:scb=\"http://www.sc.com/SCBML-1\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" + " <scb:header>\n" + " <scb:messageDetails>\n" + " <scb:messageVersion>1.0</scb:messageVersion>\n" + " <scb:messageType>\n" + " <scb:typeName>Message</scb:typeName>\n" + " <scb:subType>\n" + " <scb:subTypeName>trade</scb:subTypeName>\n" + " </scb:subType>\n" + " </scb:messageType>\n" + " </scb:messageDetails>\n" + " <scb:originationDetails>\n" + " <scb:messageSender systemScheme=\"http://www.sc.com/coding-scheme/system\">ChinaGateway</scb:messageSender>\n" + " <scb:senderDomain>\n" + " <scb:domainName domainNameScheme=\"http://www.sc.com/coding-scheme/domain-name\">FM</scb:domainName>\n" + " <scb:subDomainName subdomainNameScheme=\"http://www.sc.com/coding-scheme/sub-domain-name\">\n" + " <scb:subDomainType>SHFE</scb:subDomainType>\n" + " </scb:subDomainName>\n" + " </scb:senderDomain>\n" + " <scb:countryCode>ALL</scb:countryCode>\n" + " <scb:initiatedTimestamp>2025-02-21T02:56:53Z</scb:initiatedTimestamp>\n" + " <scb:trackingId>8c521f92-6ed9-4fe1-861b-44e7c2c94e00</scb:trackingId>\n" + " <scb:possibleDuplicate>false</scb:possibleDuplicate>\n" + " </scb:originationDetails>\n" + " <scb:captureSystem/>\n" + " <scb:process>\n" + " <scb:processName>trade</scb:processName>\n" + " <scb:eventType>STP</scb:eventType>\n" + " </scb:process>\n" + " </scb:header>\n" + " <scb:payload>\n" + " <scb:payloadFormat>XML</scb:payloadFormat>\n" + " <scb:payloadVersion>5.0</scb:payloadVersion>\n" + " <fixMessage>\n" + " <field>\n" + " <key>ActionDay</key>\n" + " <value>20250221</value>\n" + " </field>\n" + " <field>\n" + " <key>msgType</key>\n" + " <value>trade</value>\n" + " </field>\n" + " </fixMessage>\n" + " </scb:payload>\n" + "</scb:SCBML>"; java 语言 实现生成 上面的string xml
03-14
<Window x:Class="SelfMeet.Cameras.QianDaoVaid" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:SelfMeet.Cameras" xmlns:ctl="clr-namespace:SelfMeet.Controls" mc:Ignorable="d" Title="人脸验证" Height="800" Width="1400" Style="{StaticResource TixunWindow}"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="auto"/> <RowDefinition Height="auto"/> <RowDefinition Height="*"/> <RowDefinition Height="auto"/> </Grid.RowDefinitions> <Grid Grid.Row="0"> <StackPanel Orientation="Horizontal" HorizontalAlignment="Right"> <ToggleButton x:Name="bt_Set" Visibility="Collapsed" HorizontalAlignment="Right" IsChecked="{Binding IsCameSetting,Mode=TwoWay}" FontSize="36" Style="{StaticResource TixunToggleButton}" Content="≡" ToolTip="摄像头设置"/> <Popup AllowsTransparency="True" x:Name="bt_pop" IsOpen="{Binding ElementName=bt_Set,Path=IsChecked}" FlowDirection="LeftToRight" PlacementTarget="{Binding ElementName=bt_Set}" VerticalOffset="0" HorizontalOffset="-160"> <Grid Width="300" Background="#66000000" > <StackPanel Orientation="Vertical" Margin="10" > <TextBlock Text="摄像头:" Foreground="LightGray" Margin="10,0"/> <ComboBox DisplayMemberPath="Name" ItemsSource="{Binding CameraList}" SelectedItem="{Binding SLDCamera,UpdateSourceTrigger=PropertyChanged}" Margin="10,2"/> <TextBlock Text="清析度:" Foreground="LightGray" Margin="10,0"/> <ComboBox DisplayMemberPath="Name" ItemsSource="{Binding PixelList}" SelectedItem="{Binding SLDPixel,UpdateSourceTrigger=PropertyChanged}" Margin="10,2" /> <TextBlock Text="旋转:" Foreground="LightGray" Margin="10,0"/> <ComboBox ItemsSource="{Binding CameraFlipList}" SelectedItem="{Binding SLDCameraFlip,UpdateSourceTrigger=PropertyChanged}" Margin="10,2" /> <TextBlock Text="爆光度:" Foreground="LightGray" Margin="10,0"/> <DockPanel Margin="10,2"> <Button Content="-" Click="Exposure_Sub" FontSize="14" FontWeight="Bold" ToolTip="減少" DockPanel.Dock="Left" ></Button> <Button Content="+" Click="Exposure_Add" FontSize="14" FontWeight="Bold" ToolTip="增加" DockPanel.Dock="Right"></Button> <DockPanel > <TextBlock Text="{Binding MinExposure}" Foreground="LightGray" HorizontalAlignment="Right" FontSize="10" VerticalAlignment="Center" DockPanel.Dock="Left"/> <StackPanel Orientation="Horizontal" DockPanel.Dock="Right"> <TextBlock Text="{Binding MaxExposure}" FontSize="10" Margin="-3,0,5,0" Foreground="LightGray" HorizontalAlignment="Left" VerticalAlignment="Center"/> <TextBox Text="{Binding ValueExposure}" Style="{StaticResource BaseStyle}" Background="#33FFFFFF" FontSize="16" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" /> </StackPanel> <Grid> <Slider x:Name="Exposure_Value" Value="{Binding ValueExposure,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Foreground="White" TickPlacement="BottomRight" Maximum="{Binding MaxExposure}" Minimum="{Binding MinExposure}" SmallChange="{Binding SetpExposure}" VerticalAlignment="Center" /> </Grid> </DockPanel> </DockPanel> </StackPanel> </Grid> </Popup> <Button x:Name="bt_Close" PreviewMouseDown="bt_Close_PreviewMouseDown" Content="✕" Style="{StaticResource TixunToolButton}" HorizontalAlignment="Right" VerticalAlignment="Top"/> </StackPanel> </Grid> <StackPanel Orientation="Vertical" HorizontalAlignment="Center" Grid.Row="1"> <TextBlock Text="请要求待拘人员" FontSize="36" TextAlignment="Center" Foreground="White"/> <TextBlock Text="面对屏幕并保持正脸在框选区域" FontSize="36" TextAlignment="Center" Foreground="White"/> </StackPanel> <Grid Grid.Row="2" Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}},Path=ActualWidth,Converter={StaticResource RatioConverter},ConverterParameter=80}" Height="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}},Path=ActualHeight,Converter={StaticResource RatioConverter},ConverterParameter=75}" VerticalAlignment="Top"> <Border Background="#33FFFFFF" CornerRadius="20" Margin="10" HorizontalAlignment="Center" Grid.Column="0"> <Grid> <Image Name="CamImage" VerticalAlignment="Center" Margin="10" Source="{Binding CameraImage,Converter={StaticResource FaceCameraConverter}}" /> <TextBlock Text="{Binding WathTimer}" Foreground="Red" FontSize="36" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="20" /> </Grid> </Border> </Grid> <ctl:CopyVerseion Grid.Row="3" Foreground="White"/> <ProgressBar x:Name="PressBar" Grid.Row="2" Style="{StaticResource ArcProgressBarStyle}"></ProgressBar> </Grid> </Window> 这是源代码,报错是这行 <ctl:CopyVerseion Grid.Row="3" Foreground="White"/>
最新发布
08-07
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值